var buy_order = {
	//结算页相关ajax的url
	URL: {
		province: function() {
			return global_ajaxdomain + 'getprovince.jhtm?t=' + new Date().getTime();
		},
		cities: function() {
			return global_ajaxdomain + 'getcities.jhtm?t=' + new Date().getTime();
		},
		counties: function() {
			return global_ajaxdomain + 'getcounties.jhtm?t=' + new Date().getTime();
		},
		villages: function() {
			return global_ajaxdomain + 'getvillages.jhtm?t=' + new Date().getTime();
		},
		zip: function() {
			return global_ajaxdomain + 'getzip.jhtm?t=' + new Date().getTime();
		},
		addconsignee: function() {
			return global_ajaxdomain + 'consignee/addconsignee.jhtm?t=' + new Date().getTime();
		},
		updateconsignee: function() {
			return global_ajaxdomain + 'consignee/updateconsignee.jhtm?t=' + new Date().getTime();
		},
		deleteconsignee: function() {
			return global_ajaxdomain + 'consignee/deleteconsignee.jhtm?t=' + new Date().getTime();
		},
		getCheckOutData: function() {
			return global_ajaxdomain + 'getCheckOutData.jhtm?t=' + new Date().getTime();
		},
		usevirtualcurrency: function() {
			return global_ajaxdomain + 'usevirtualcurrency.jhtm?t=' + new Date().getTime();
		},
		datarecovery: function() {
			return global_ajaxdomain + "checkRecoveryService.jhtm?t=" + new Date().getTime();
		},
		updateMoreCheckOutCache: function() {
			return global_ajaxdomain + 'updateMoreCheckOutCache.jhtm?t=' + new Date().getTime();
		},
		updateCheckOutCache: function() {
			return global_ajaxdomain + 'updateCheckOutCache.jhtm?t=' + new Date().getTime();
		},
		submitOrder: function() {
			return global_ajaxdomain + 'submitOrder.jhtm?t=' + new Date().getTime();
		},
		getcart: function() {
			return global_ajaxdomain + 'getcart.jhtm?terminal=' + terminal + '&t=' + new Date().getTime();
		},
		checkServiceSNCode: function() {
			return global_ajaxdomain + "checkSNCode.jhtm?t=" + new Date().getTime();
		}
	}
};
var products_c = null;
//修改ie 下 trim 不支持的bug
String.prototype.trim = function() {
	return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
var shareConsigneeId = null;
var shareInvoiceAddressId = "";
var shareContractAddressId = "";
var invoiceFaid = "";
var iso2o = false;
var isPreSale = false;
var iscto = false;
var isCrowdunding = false;
var couponidArr = [];
var couponidTempArr = [];
/*定义结算缓存更新项“枚举”*/
if(typeof UpdateBackFillItem == "undefined") {
	var UpdateBackFillItem = {};
	UpdateBackFillItem.DELIVER = 1; //更新地址
	UpdateBackFillItem.INVOICE = 2; //发票
	UpdateBackFillItem.PAYTYPE = 3; //支付方式
	UpdateBackFillItem.CMANNAGER_CODE = 4; //客服经理编码
	UpdateBackFillItem.ORDER_REMARK = 5; //订单备注
	UpdateBackFillItem.COUPONIDS = 6; //优惠券
	UpdateBackFillItem.COUPONCODE = 7; //优惠码
	UpdateBackFillItem.INNERBUYMONEY = 8; //内购
	UpdateBackFillItem.GIFTCARES = 9; //礼品卡
	UpdateBackFillItem.HAPPYBEAN = 10; //乐豆
	UpdateBackFillItem.SN = 11; //SN码
	UpdateBackFillItem.IDENTITY_ID = 12; //身份信息验证ID
	UpdateBackFillItem.DATARECOVERY = 14; //数据恢复险
	UpdateBackFillItem.INVOICEADDRESS = 15; //收票地址
	UpdateBackFillItem.INVOICEISCONSIGNEE = 16; //收票地址是否同收货地址
	UpdateBackFillItem.CONTRACTADDRESS = 17; //合同地址
	UpdateBackFillItem.CONTRACTISCONSIGNEE = 18; //合同地址是否同收货地址
	UpdateBackFillItem.ISSENDCONTRACT = 19; //是否寄送合同
	UpdateBackFillItem.PRESELLTEL = 20; //预售电话
	UpdateBackFillItem.CREDITINFO = 21; //惠商信用额度
	UpdateBackFillItem.DELEVER_GOODS_TYPE = 22;
	UpdateBackFillItem.CASHMONEY = 25; //代金券金额
}
/*address enum*/
if(typeof AddressTypeEnums == 'undefined') {
	var AddressTypeEnums = {};
	AddressTypeEnums.DONGDE = "dongde"; //懂得收货地址
	AddressTypeEnums.SH = "SH"; //收货地址
	AddressTypeEnums.SP = "SP"; //收票地址
	AddressTypeEnums.HT = "HT"; //合同地址
}

function showAdd(addresstype) {
	$("#bg-" + addresstype).css({
		display: "block",
		height: $(document).height()
	});
	var $box = $('.box-' + addresstype);
	var $showbtn = $('.showbtn-' + addresstype);
	$box.css({
		//设置弹出层距离左边的位置
		"left": ($("body").width() - $box.width()) / 2 + "px",
		//设置弹出层距离上面的位置
		"top": ($(".showbtn-" + addresstype).offset().top + $showbtn.height()) + 10 + "px",
		display: "block"
	});
	//新增默认选中
	$("#isCheck-" + addresstype).attr("checked", 'true');
	//$("#isCheck").removeAttr("checked");
	$.ajax({
		type: "get",
		url: buy_order.URL.province(),
		async: false,
		dataType: "json",
		success: function(data) {
			if(data != null) {
				if(data.success && data.t.length > 0) {
					for(var i = 0; i < data.t.length; i++) {
						var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
						$("#goodsProvince-" + addresstype).append(option);
					}
				}
			}
		}
	});
	var loginname = passport.cookie.loginName;
	if(loginname.indexOf("@") > -1) {
		$("#mail-SH").val(loginname);
	} else {
		$("#mobile-SH").val(loginname);
	}
}

function closeAlert(addresstype) {
	$("#bg-" + addresstype + ",.box-" + addresstype).css("display", "none");
	$("#flag1-" + addresstype).val("0");
	$("#name-" + addresstype).val("");
	$("#mobile-" + addresstype).val("");
	$("#goodsStreet-" + addresstype).val("");
	$("#postcode-" + addresstype).val("");
	$("#mail-" + addresstype).val("");
	$("#isCheck-" + addresstype).attr("checked", "true");
	$("#goodsProvince-" + addresstype).find("option").remove();
	$("#goodsProvince-" + addresstype).append('<option value="">' + orderResource.province + '</option>');
	$("#goodsCity-" + addresstype).find("option").remove();
	$("#goodsCity-" + addresstype).append('<option value="">' + orderResource.city + '</option>');
	$("#goodsCounty-" + addresstype).find("option").remove();
	$("#goodsCounty-" + addresstype).append('<option value="">' + orderResource.county + '</option>');
	$("#phone-" + addresstype).val("");
	$("#zip-" + addresstype).val("");
	$("#goodsVillage-" + addresstype).find("option").remove();
	$("#goodsVillage-" + addresstype).append('<option value="">' + orderResource.village + '</option>');
	$("#company-" + addresstype).val("");
	$("#submitbtn-" + addresstype).attr("disabled", false).html(orderResource.save_receiver_info);
}

function getCities(addresstype) {
	var province = $("#goodsProvince-" + addresstype).find("option:selected").text();
	if(province != "") {
		$.ajax({
			type: "get",
			url: buy_order.URL.cities(),
			async: false,
			data: {
				provincename: encodeURIComponent(province, "utf-8")
			},
			dataType: "json",
			success: function(data) {
				if(data != null) {
					if(data.success && data.t.length > 0) {
						$("#goodsCity-" + addresstype).find("option").remove();
						var option = "<option>" + orderResource.city + "</option>";
						$("#goodsCity-" + addresstype).append(option);
						$("#goodsCounty-" + addresstype).find("option").remove();
						option = "<option>" + orderResource.county + "</option>";
						$("#goodsCounty-" + addresstype).append(option);
						$("#goodsVillage-" + addresstype).find("option").remove();
						option = "<option>" + orderResource.village + "</option>";
						$("#goodsVillage-" + addresstype).append(option);
						for(var i = 0; i < data.t.length; i++) {
							var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
							$("#goodsCity-" + addresstype).append(option);
						}
					}
				}
			}
		});
	}
}

function getCounties(addresstype) {

	var city = $("#goodsCity-" + addresstype).find("option:selected").text();
	var province = $("#goodsProvince-" + addresstype).find("option:selected").text();
	if(city != "") {
		$.ajax({
			type: "get",
			url: buy_order.URL.counties(),
			async: false,
			data: {
				provincename: encodeURIComponent(province, "utf-8"),
				cityname: encodeURIComponent(city, "utf-8")
			},
			dataType: "json",
			success: function(data) {
				if(data != null) {
					if(data.success && data.t.length > 0) {
						$("#goodsCounty-" + addresstype).find("option").remove();
						var option = "<option>" + orderResource.county + "</option>";
						$("#goodsCounty-" + addresstype).append(option);
						$("#goodsVillage-" + addresstype).find("option").remove();
						option = "<option>" + orderResource.village + "</option>";
						$("#goodsVillage-" + addresstype).append(option);
						//if(shopId == 14 || shopId ==15){
						//    for (var i = 0; i < data.counties.split(',').length; i++) {
						//        var option = "<option value='"+data.counties.split(',')[i].split("|")[1]+"'>" + data.counties.split(',')[i].split("|")[0] + "</option>";
						//        $("#goodsCounty-" + addresstype).append(option);
						//    }
						//}else{
						//    for (var i = 0; i < data.counties.split(',').length; i++) {
						//        var option = "<option>" + data.counties.split(',')[i] + "</option>";
						//        $("#goodsCounty-" + addresstype).append(option);
						//    }
						//}
						for(var i = 0; i < data.t.length; i++) {
							var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
							$("#goodsCounty-" + addresstype).append(option);
						}
					}
				}
			}
		});
		if(shopId == 8 || shopId == 9) {
			getZip(province, city, addresstype)
		}
	}

}
/*get smb zip */
function getZip(province, city, addresstype) {

	if(city != "") {
		$.ajax({
			type: "get",
			url: buy_order.URL.zip(),
			async: false,
			data: {
				provincename: encodeURIComponent(province, "utf-8"),
				cityname: encodeURIComponent(city, "utf-8")
			},
			dataType: "json",
			success: function(data) {
				if(data != null && data.success) {
					$("#zip-" + addresstype).val(data.t);
				}
			}
		});
	}
}

function getVillages(addresstype) {

	var province = $("#goodsProvince-" + addresstype).find("option:selected").text();
	var city = $("#goodsCity-" + addresstype).find("option:selected").text();
	var county = $("#goodsCounty-" + addresstype).find("option:selected").text();
	if(county != "") {
		$.ajax({
			type: "get",
			url: buy_order.URL.villages(),
			async: false,
			data: {
				provincename: encodeURIComponent(province, "utf-8"),
				cityname: encodeURIComponent(city, "utf-8"),
				countryname: encodeURIComponent(county, "utf-8")
			},
			dataType: "json",
			success: function(data) {
				if(data != null) {
					if(data.success && data.t.length > 0) {
						$("#goodsVillage-" + addresstype).find("option").remove();
						var option = "<option>" + orderResource.village + "</option>";
						$("#goodsVillage-" + addresstype).append(option);
						//for (var i = 0; i < data.district.split(',').length; i++) {
						//    var option = "<option>" + data.district.split(',')[i] + "</option>";
						//    $("#goodsVillage-" + addresstype).append(option);
						//}
						for(var i = 0; i < data.t.length; i++) {
							var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
							$("#goodsVillage-" + addresstype).append(option);
						}
					}
				}
			}
		});
	}
}

function getStringLengthForChinese(val) {
	var str = new String(val);
	var bytesCount = 0;
	for(var i = 0, n = str.length; i < n; i++) {
		var c = str.charCodeAt(i);
		if((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
			bytesCount += 1;
		} else {
			bytesCount += 2;
		}
	}
	return bytesCount;
}
//保存收货地址
function submitInfo(addresstype) {
	var temp_value = null;
	var type_name = "";
	/*default sh address*/
	if(addresstype == AddressTypeEnums.DONGDE) {
		var goodsProvince = $("#s_province").find("option:selected").text();
		var goodsCity = $("#s_city").find("option:selected").text();
		var goodsCounty = $("#s_county").find("option:selected").text();
		//编码
		var s_province = $("#s_province").find("option:selected").val();
		var s_city = $("#s_city").find("option:selected").val();
		var s_county = $("#s_county").find("option:selected").val();
	} else {
		var goodsProvince = $("#goodsProvince-" + addresstype).find("option:selected").text();
		var goodsCity = $("#goodsCity-" + addresstype).find("option:selected").text();
		var goodsCounty = $("#goodsCounty-" + addresstype).find("option:selected").text();
		var goodsVillage = $("#goodsVillage-" + addresstype).find("option:selected").text();
		//编码
		var s_province = $("#goodsProvince-" + addresstype).find("option:selected").val();
		var s_city = $("#goodsCity-" + addresstype).find("option:selected").val();
		var s_county = $("#goodsCounty-" + addresstype).find("option:selected").val();
		var s_village = $("#goodsVillage-" + addresstype).find("option:selected").val();
	}

	temp_value = $("#name-" + addresstype).val();
	if(isEmpty(temp_value)) {
		alert(orderResource.input_receiver_name);
		return false;
	}
	if(getStringLengthForChinese(temp_value) > 20) {
		alert(orderResource.receiver_name_exceed);
		return false;
	}
	if(!is_forbid(temp_value)) {
		alert(orderResource.receiver_name_include_illegal_character);
		return false;
	}

	/*  var containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\')(\")(\,)(\.)(\/)(\<)(\>)(\?)(\)]+/);
	 if (containSpecial.test($("#name-" + addresstype).val().trim())) {
	 alert('请输入正确' + type_name + '人姓名');
	 return false;
	 }
	 */
	temp_value = $("#company-" + addresstype).val();
	if(temp_value != undefined && isEmpty(temp_value)) {
		alert(orderResource.input_receiver_company);
		return false;
	}
	if(temp_value != undefined && !is_forbid(temp_value)) {
		alert(orderResource.company_name_include_illegal_character);
		return false;
	}

	var phone = $("#phone-" + addresstype).val();
	var mobile = $("#mobile-" + addresstype).val();
	if(isEmpty(mobile)) {
		alert(orderResource.input_receiver_mobile_phone_number);
		return false;
	}

	if(!isEmpty(mobile)) {
		var reg = /^1[3-9]\d{9}$/;
		if(!reg.test(mobile)) {
			alert(orderResource.incorrect_mobile_phone_number);
			return false;
		}
	}
	if(!isEmpty(phone)) {
		if(!is_forbid_new(phone)) {
			alert(orderResource.telephone_number_include_illegal_character);
			return false;
		}
		if(!checkPhoneNew(mobile, phone)) {
			alert(orderResource.format_telephone_number);
			return false;
		}
	}
	if(goodsProvince == orderResource.province || goodsCity == orderResource.city || goodsCounty == orderResource.county) {
		alert(orderResource.select_correct_address);
		return false;
	}
	if((shopId == 8 || shopId == 9 || shopId == 1 || shopId == 3) && goodsVillage == orderResource.village) {
		alert(orderResource.select_correct_village);
		return false;
	}
	temp_value = $("#goodsStreet-" + addresstype).val();
	if(isEmpty(temp_value)) {
		alert(orderResource.input_address_detail);
		return false;
	}
	if(!is_forbid(temp_value)) {
		alert(orderResource.address_detail_include_illegal_character);
		return false;
	}
	if(temp_value.length > 250) {
		alert(orderResource.address_detail_exceed);
		return false;
	}
	temp_value = $("#zip-" + addresstype).val();
	if(temp_value != undefined) {
		if(isEmpty(temp_value)) {
			alert(orderResource.input_postal_code);
			return false;
		} else if(!isNumber(temp_value) || $.trim(temp_value).length != 6) {
			alert(orderResource.incorrect_postal_code);
			return false;
		}
	}

	temp_value = $("#mail-" + addresstype).val();
	if(temp_value != "" && !temp_value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
		alert(orderResource.email_format_incorrect);
		return false;
	}

	if(temp_value.length > 100) {
		alert(orderResource.email_address_exceed);
		return false;
	}
	$("#submitbtn-" + addresstype).attr("disabled", true).html(orderResource.submitting);
	var name = $.trim($("#name-" + addresstype).val());
	var mobile = $.trim($("#mobile-" + addresstype).val());
	var goodsStreet = $.trim($("#goodsStreet-" + addresstype).val());
	var mail = $.trim($("#mail-" + addresstype).val());
	var flag = $.trim($("#flag1-" + addresstype).val());
	var deliverid = $.trim($("#deliveridupdate-" + addresstype).val());
	var isdefault = $("#isCheck-" + addresstype).is(':checked') ? 1 : 0;
	var zip = $.trim($("#zip-" + addresstype).val());
	var company = $.trim($("#company-" + addresstype).val());
	/*Default shipping address*/
	var ajaxdata = {
		delivername: CtoH(name),
		deliverprovice: goodsProvince,
		delivercity: goodsCity,
		delivercounty: goodsCounty,
		deliverStreet: CtoH(goodsStreet),
		delivertele: CtoH(phone),
		delivermobile: CtoH(mobile),
		deliveremail: CtoH(mail),
		isDefault: isdefault,
		deliverid: deliverid,
		zip: CtoH(zip),
		type: addresstype
	};
	if(addresstype == AddressTypeEnums.DONGDE) {
		ajaxdata.areaNos = s_province + "|" + s_city + "|" + s_county;
		ajaxdata.provinceNo = s_province;
		ajaxdata.cityNo = s_city;
		ajaxdata.countyNo = s_county;
	} else {
		if(shopId == 8 || shopId == 9) {
			ajaxdata.company = CtoH(company);
			if(addresstype == AddressTypeEnums.SH) {
				ajaxdata.towerShip = goodsVillage;
				//ajaxdata.townshipNo = s_village;
			}
		} else {
			ajaxdata.towerShip = goodsVillage;
			ajaxdata.provinceNo = s_province;
			ajaxdata.cityNo = s_city;
			ajaxdata.countyNo = s_county;
			ajaxdata.townshipNo = s_village;
		}
	}
	$.ajax({
		type: "post",
		url: flag == 1 ? buy_order.URL.updateconsignee() : buy_order.URL.addconsignee(),
		async: false,
		data: ajaxdata,
		dataType: "json",
		success: function(data) {
			$("#submitbtn-" + addresstype).attr("disabled", false).html(orderResource.save_receiver_info);
			if(data != null) {
				if(data.rc != null && data.rc == "0") {
					if(isdefault == 0) {
						updateCheckOutCacheAddress(addresstype, "A");
					} else {
						if(flag == 1) {
							updateCheckOutCacheAddress(addresstype, "A" + deliverid);
						} else {
							updateCheckOutCacheAddress(addresstype, "A" + data.data);
						}
					}
				} else {
					closeAlert();
					//showMessage(3000, "系统繁忙，请稍后再试！");
					showMessage(3000, data.msg);
				}
			}
		},
		error: function() {
			$("#submitbtn-" + addresstype).attr("disabled", false).html(orderResource.save_receiver_info);
		}
	});

}
/*update cache by addresstype */
function updateCheckOutCacheAddress(addresstype, content) {
	var updateItem;
	if(addresstype == AddressTypeEnums.DONGDE || addresstype == AddressTypeEnums.SH) {
		updateItem = UpdateBackFillItem.DELIVER;
	} else if(addresstype == AddressTypeEnums.SP) {
		updateItem = UpdateBackFillItem.INVOICEADDRESS;
	} else if(addresstype == AddressTypeEnums.HT) {
		updateItem = UpdateBackFillItem.CONTRACTADDRESS;
	}
	updateCheckOutCache(updateItem, content);
}

$(function() {
	$(".showbtna").click(function() {
		// $(".box").hide();
		$("#bg").css({
			display: "block",
			height: $(document).height()
		});
		var $boxa = $('.boxa');
		var $showbtna = $('.showbtna');
		$boxa.css({
			//设置弹出层距离左边的位置
			"left": ($("body").width() - $boxa.width()) / 2 + "px",
			//设置弹出层距离上面的位置
			"top": ($showbtna.offset().top + $showbtna.height()) + 10 + "px",
			display: "block"
		});

		var head = $("#invoice_header").val();
		var type = $("#invoice_type").html();
		var data = {};
		if(head == "1") {
			$("#Radioheadtype2").prop("checked", "true");
			$("#invoiceheadcontent").attr("placeholder", orderResource.company_title);
			$("#tempinvoiceType_p").hide();
			$("#tempinvoiceType_c").show();
			if(type == orderResource.value_added_tax_invoice) {
				$("#12").prop("checked", "true");
				showZZInvoice();
			} else {
				if(type == orderResource.normal_invoice) {
					$("#11").prop("checked", "true");
				} else {
					$("#10").prop("checked", "true");
				}
				var invoice_head = $("#invoice_head").html();
				var invoice_tax = $("#invoice_tax").val();
				var companytype = $("#invoice_companytype").val();
				canEdit();
				$("#invoiceheadcontent").val(invoice_head);
				$("#companytypeli").css("display", "inline-table");
				$("#companytypetip").css("display", "inline-table");
				if(typeof(companytype) != "undefined") {
					$("#companytype").val(companytype);
				}

			}
		}
		if(head == "0") {
			$("#Radioheadtype1").prop("checked", "true");
			$("#invoiceheadcontent").attr("placeholder", orderResource.individual);
			$("#tempinvoiceType_c").hide();
			$("#tempinvoiceType_p").show();
			var invoice_head = $("#invoice_head").html();
			if(type == orderResource.normal_invoice) {
				$("#01").prop("checked", "true");
				canEdit();
			} else {
				$("#00").prop("checked", "true");
				canEdit();
			}
			$("#invoiceheadcontent").val(invoice_head);
		}
	});
	//点击关闭按钮的时候，遮罩层关闭
	$(".close").click(function() {
		$("#fapinfoid").css("display", "none")
		$("#bg,.boxa").css("display", "none");
	});

	//CTO
	$('.box_xq h2').bind('mouseenter', function() {
		$(this).siblings('ul').slideDown(300);
	});
	$('.box_xq').bind('mouseleave', function() {
		$(this).find('ul').slideUp(300);
	});

});

function modifyInvoice() {
	$("#bg").css({
		display: "block",
		height: $(document).height()
	});
	var $boxa = $('.boxa');
	var $showbtna = $('.modifyInvoice');
	$boxa.css({
		//设置弹出层距离左边的位置
		"left": ($("body").width() - $boxa.width()) / 2 + "px",
		//设置弹出层距离上面的位置
		"top": 100 + "px",
		display: "block"
	});

	var data = {};
	$("#Radioheadtype2").prop("checked", "true");
	$("#invoiceheadcontent").attr("placeholder", orderResource.company_title);
	$("#tempinvoiceType_p").hide();
	$("#tempinvoiceType_c").show();
	if(type == orderResource.value_added_tax_invoice) {
		$("#12").prop("checked", "true");
		showZZInvoice();
	} else {
		$("#11").prop("checked", "true");
		var invoice_head = $("#invoice_head").html();
		canEdit();
		$("#invoiceheadcontent").val(invoice_head);
	}

}

$(function() {
	$('.menuTitle').click(function() {
		if($(this).siblings('.menuContent').css('display') == 'none') {
			$(this).siblings('.menuContent').css('display', 'block');
			$(this).find('a').addClass('add');
		} else {
			$(this).siblings('.menuContent').css('display', 'none');
			$(this).find('a').removeClass('add');
		}
	});

});

$(function() {
	navTopDown();
})

function navTopDown() {
	$('.ns_top_title').bind('mouseenter', function() {
		$(this).siblings('ul').slideDown(300);
		$(this).find('a').removeClass('ns_top_down').addClass('ns_top_up');
	});
	$('.ns_top_link').bind('mouseleave', function() {
		$(this).find('ul').slideUp(300);
		$(this).find('.ns_top_title').find('a').removeClass('ns_top_up').addClass('ns_top_down');
	})
}

//tab切换
function aCheck1() {
	document.getElementById("tab_01").style.display = "block";
	document.getElementById("tab_02").style.display = "none";
}

function bCheck2() {
	document.getElementById("tab_01").style.display = "none";
	document.getElementById("tab_02").style.display = "block";
}

$(function() {
	$('.hong').click(function() {
		$('.hong').removeClass('aa');
		$(this).addClass('aa');
	});
})

//切换支付方式
function choosePay(i) {
	$("#bgdiv" + i).addClass("pink").siblings().removeClass("pink");
	updatePayType(); //更新支付方式的缓存
}

function chooseAddress(i, addresstype) {
	$("#chooseid-" + addresstype).val(i);
	$(".address-" + addresstype).removeClass("pink");
	$("#bgdiv" + i).addClass("pink");
	if(addresstype == AddressTypeEnums.SP) {
		updateAddressCache(i, addresstype);
	} else {
		usevirtualcurrency(UpdateBackFillItem.DELIVER, i);
	}

}

function getPayWay() {
	var boxArr = $("#box-b").find(".box-ax");
	var paytype = "0";
	for(var i = 0; i < boxArr.length; i++) {
		if($("#box-b").find(".box-ax").eq(i).hasClass("pink")) {
			paytype = $("#box-b").find("div.box-ax")[i].id.substring(5);
		}
	}
	return paytype;
}

function getChoseId(addresstype) {
	return $("#chooseid-" + addresstype).val();
}

function deleteAddress_(deliverid, addresstype, event) {
	opencover(orderResource.delete_operate, orderResource.confirmed_to_delete, "deleteAddress('" + deliverid + "','" + addresstype + "')");
	//JS停止冒泡
	window.event ? window.event.cancelBubble = true : event.stopPropagation();
}

function deleteAddress(deliverid, addresstype) {

	var ajaxdata = {
		deliverid: deliverid,
		type: addresstype
	};
	$.ajax({
		type: "post",
		url: buy_order.URL.deleteconsignee(),
		async: false,
		data: ajaxdata,
		dataType: "json",
		success: function(data) {
			if(data != null) {
				if(data.rc == 0) {
					closecover();
					updateCheckOutCacheAddress(addresstype, "D" + deliverid);
				}
			}
		}
	});
}

/*获取选中的礼品卡*/
function getCheckedCashCardNos() {
	var cashCardNos = "";
	var cashCardMoney = "0.00";
	//内购额度
	var isLimitMoney = $('#innerLimitMoney').val();
	var item = $('input[type="checkbox"][name="cashCardCheckbox"]:checked');
	$.each(item, function(i, element) {
		if(isLimitMoney != "" && null != isLimitMoney && 'undefined' != isLimitMoney) {
			showMessage(3000, orderResource.gift_card_and_inner_money_did_not_work_together);
			return;
		}
		var str = $(element).val().split(',');
		for(var j = 0; j < 1; j++) {
			cashCardMoney = parseFloat(cashCardMoney) + parseFloat(str[1]);
			cashCardNos += str[0] + '@'; //，将value添加到变量s中
		}
	});
	var lastChar = "";
	if(cashCardNos == null || cashCardNos == 'undefined' || cashCardNos == "") {
		lastChar = "";
	} else {
		lastChar = cashCardNos.lastIndexOf('@');
	}
	if(lastChar > 0) { //去除多于的@
		cashCardNos.substring(0, cashCardNos.length - 1);
	}
	$('#cashCardNum').text(item.length);
	$('#cashCardMoney').text(cashCardMoney);
	return cashCardNos;
}

/*update address (Multiple)*/
function updateAddress(village, company, zip, deliverid, delivername, delivermobile, deliverprovice, delivercity, delivercounty, deliverStreet, mail, isDefault, delivertele, areaNos, addresstype, event) {

	$("#bg-" + addresstype).css({
		display: "block",
		height: $(document).height()
	});
	var $box = $('.box-' + addresstype);
	var $showbtn = $('.showbtn-' + addresstype);
	$box.css({
		//设置弹出层距离左边的位置
		"left": ($("body").width() - $box.width()) / 2 + "px",
		//设置弹出层距离上面的位置
		"top": ($showbtn.offset().top + $showbtn.height()) + 10 + "px",
		display: "block"
	});
	$("#flag1-" + addresstype).val("1");
	/*render  Area*/
	if(addresstype == AddressTypeEnums.SH || addresstype == AddressTypeEnums.SP || addresstype == AddressTypeEnums.HT) {
		renderArea(deliverprovice, delivercity, delivercounty, village, addresstype);
	} else if(addresstype == AddressTypeEnums.DONGDE) {
		if(!getCheckEmpty(areaNos)) {
			var anoArr = areaNos.split("|");
			$("#s_province").val(anoArr[0]);
			change(1);
			$("#s_city").val(anoArr[1]);
			change(2);
			$("#s_county").val(anoArr[2]);
		}
	}
	$("#deliveridupdate-" + addresstype).val(deliverid);
	$("#name-" + addresstype).val(delivername);
	$("#mobile-" + addresstype).val(delivermobile);
	$("#goodsStreet-" + addresstype).val(deliverStreet);
	if(getCheckEmpty(mail)) {
		$("#mail-" + addresstype).val("");
	} else {
		$("#mail-" + addresstype).val(mail);
	}
	if(getCheckEmpty(delivertele)) {
		$("#phone-" + addresstype).val("");
	} else {
		$("#phone-" + addresstype).val(delivertele);
	}

	if(isDefault == "1") {
		$("#isCheck-" + addresstype).prop("checked", "true");
	} else if(isDefault == "0") {
		$("#isCheck-" + addresstype).removeAttr("checked");
	}
	if($("#zip-" + addresstype).val() != undefined) {
		$("#zip-" + addresstype).val(zip);
	}
	if($("#company-" + addresstype).val() != undefined) {
		$("#company-" + addresstype).val(company);
	}
	//JS停止冒泡
	window.event ? window.event.cancelBubble = true : event.stopPropagation();
}
/*sh render provice city county*/
function renderArea(deliverprovice, delivercity, delivercounty, village, addresstype) {
	$.ajax({
		type: "get",
		url: buy_order.URL.province(),
		async: false,
		dataType: "json",
		success: function(data) {
			if(data != null) {
				if(data.success && data.t.length > 0) {
					for(var i = 0; i < data.t.length; i++) {
						var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
						$("#goodsProvince-" + addresstype).append(option);
					}
					var count = $("#goodsProvince-" + addresstype + " option").length;
					for(var i = 0; i < count; i++) {
						if($("#goodsProvince-" + addresstype).get(0).options[i].text == deliverprovice) {
							$("#goodsProvince-" + addresstype).get(0).options[i].selected = true;
							break;
						}
					}
					var province = $("#goodsProvince-" + addresstype).find("option:selected").text();
					if(province != "") {
						$.ajax({
							type: "get",
							url: buy_order.URL.cities(),
							async: false,
							data: {
								provincename: encodeURIComponent(province, "utf-8")
							},
							dataType: "json",
							success: function(data) {
								if(data != null) {
									if(data.success && data.t.length > 0) {
										$("#goodsCity-" + addresstype).find("option").remove();
										for(var i = 0; i < data.t.length; i++) {
											var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
											$("#goodsCity-" + addresstype).append(option);
										}
									}
									count = $("#goodsCity-" + addresstype + " option").length;
									for(var i = 0; i < count; i++) {
										if($("#goodsCity-" + addresstype).get(0).options[i].text == delivercity) {
											$("#goodsCity-" + addresstype).get(0).options[i].selected = true;
											break;
										}
									}
									var city = $("#goodsCity-" + addresstype).find("option:selected").text();
									if(city != "") {
										$.ajax({
											type: "get",
											url: buy_order.URL.counties(),
											async: false,
											data: {
												provincename: encodeURIComponent(province, "utf-8"),
												cityname: encodeURIComponent(city, "utf-8")
											},
											dataType: "json",
											success: function(data) {
												if(data != null) {
													if(data.success && data.t.length > 0) {
														$("#goodsCounty-" + addresstype).find("option").remove();
														//for (var i = 0; i < data.counties.split(',').length; i++) {
														//    var option = "<option>" + data.counties.split(',')[i] + "</option>";
														//    $("#goodsCounty-" + addresstype).append(option);
														//}
														for(var i = 0; i < data.t.length; i++) {
															var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
															$("#goodsCounty-" + addresstype).append(option);
														}
														count = $("#goodsCounty-" + addresstype + " option").length;
														for(var i = 0; i < count; i++) {
															if($("#goodsCounty-" + addresstype).get(0).options[i].text == delivercounty) {
																$("#goodsCounty-" + addresstype).get(0).options[i].selected = true;
																break;
															}
														}
														if(shopId == 8 || shopId == 9 || shopId == 1 || shopId == 3) {
															var county = $("#goodsCounty-" + addresstype).find("option:selected").text();
															if(county != "") {
																$.ajax({
																	type: "get",
																	url: buy_order.URL.villages(),
																	async: false,
																	data: {
																		provincename: encodeURIComponent(province, "utf-8"),
																		cityname: encodeURIComponent(city, "utf-8"),
																		countryname: encodeURIComponent(county, "utf-8")
																	},
																	dataType: "json",
																	success: function(data) {
																		if(data != null) {
																			if(data.success && data.t.length > 0) {
																				$("#goodsVillage-" + addresstype).find("option").remove();
																				//for (var i = 0; i < data.district.split(',').length; i++) {
																				//    var option = "<option>" + data.district.split(',')[i] + "</option>";
																				//    $("#goodsVillage-" + addresstype).append(option);
																				//}
																				for(var i = 0; i < data.t.length; i++) {
																					var option = "<option value='" + data.t[i].code + "' >" + data.t[i].name + "</option>";
																					$("#goodsVillage-" + addresstype).append(option);
																				}
																				count = $("#goodsVillage-" + addresstype + " option").length;
																				for(var i = 0; i < count; i++) {
																					if($("#goodsVillage-" + addresstype).get(0).options[i].text == village) {
																						$("#goodsVillage-" + addresstype).get(0).options[i].selected = true;
																						break;
																					}
																				}
																			}
																		}
																	}
																});
															}
														}

													}
												}
											}
										});
									}
								}
							}
						});
					}
				}
			}
		}
	});
}

/////////////////////////////////////////////////
//获取数据（渲染、展示）--开始
////////////////////////////////////////////////
/*
 * 获取结算页数据进行渲染（只有影响到价格的或者跳转页面的才能重新调用）
 * 1.url  ,链接域名
 * 2.terminal 终端
 */
function getcheckOutData(url, terminal) {
	$.post(buy_order.URL.getCheckOutData(url), {
		lid: lid,
		shopId: shopId,
		terminal: terminal
	}, function(data) {
		if(data.rc != 0) {
			/* if(data.rc != 20101){
			 showMessage(3000,data.msg);
			 }*/
			if(data.rc == 10014 || data.rc == 20101 || data.rc == 10010) {
				window.location.href = buy_order.URL.getcart();
			} else {
				showMessage(3000, data.msg);
				$(".ui-mask").css("display", "none");
				$(".purchase-loading").css("display", "none");
			}
			return;
		}
		var temp = data.data.checkOutOrder; // 渲染
		var order = data.data.bfOrderVo; // 回显(结算缓存对象)
		if(temp != null) {
			renderPage(temp, order, null);
		}
		try {
			checkout_init_monitor(temp)
		} catch(e) {}
		$(".ui-mask").css("display", "none");
		$(".purchase-loading").css("display", "none");
	}, 'json');
}
/*
 * 获取结算页数据进行渲染（只有影响到价格的或者跳转页面的才能重新调用）
 * 1.url  ,链接域名
 * 2.terminal 终端
 */
function getcheckOutDataNew(url, terminal, updateItem) {
	$.post(buy_order.URL.getCheckOutData(url), {
		lid: lid,
		shopId: shopId,
		terminal: terminal
	}, function(data) {
		if(data.rc != 0) {
			cleanInput(updateItem, 2); //获取数据失败，附空缓存
			/*if(data.rc != 20101){
			 showMessage(3000,data.msg);
			 }*/
			if(data.rc == 10014 || data.rc == 20101 || data.rc == 10010) {
				window.location.href = buy_order.URL.getcart();
			} else {
				showMessage(3000, data.msg);
			}
			return;
		}
		var temp = data.data.checkOutOrder; //渲染
		var order = data.data.bfOrderVo; //回显
		if(temp != null) {
			renderPage(temp, order, updateItem);
		}
		try {
			checkout_init_monitor(temp)
		} catch(e) {}
	}, 'json');
}

function checkout_init_monitor(res) {
	try {
		var lenovo_id = passport.cookie.lenovoId;
		(function(i, s, o, g, r, a, m) {
			i['GoogleAnalyticsObject'] = r;
			i[r] = i[r] || function() {
				(i[r].q = i[r].q || []).push(arguments)
			}, i[r].l = 1 * new Date();
			a = s.createElement(o),
				m = s.getElementsByTagName(o)[0];
			a.async = 1;
			a.src = g;
			m.parentNode.insertBefore(a, m)
		})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

		ga('create', 'UA-110299082-1', 'auto', {
			userId: lenovo_id,
			allowLinker: true
		});
		ga('require', 'ec');
		ga(function(tracker) {
			var clientId = tracker.get('clientId');
			ga('set', 'dimension1', clientId);
		});
		ga('set', 'dimension2', lenovo_id);
		ga('set', 'dimension3', getCookie("LenovoCookieID"));
		ga('require', 'linker');
		ga('linker:autoLink', ['lenovo.com.cn', 'lenovo.cn', 'lenovovip.com.cn', 'lenovo.com']);
		ga('set', 'transport', 'beacon');
		ga('send', 'pageview');

		//cart global
		cart = [];
		var ids = [];
		var vendors = res.checkOutCart.vendors;

		for(var i = 0; i < vendors.length; i++) {
			var vendor = vendors[i];
			var sorted = vendor.sorted;
			for(var j = 0; j < sorted.length; j++) {
				var sort = sorted[j];
				var type = sort.itemType;
				var item = sort.item;
				if(type != 0) {
					var skus = item.skus;
					if(skus) {
						for(var k = 0; k < skus.length; k++) {
							var sku = skus[k];
							parseSku(sku, cart, ids);
						}
					}
				} else {
					parseSku(item, cart, ids);
				}
			}
		}

		checkout_monitor(cart);

		ga('ec:setAction', 'checkout', {
			'step': 3
		});
		ga('send', 'event', "ProductEC_PC", "ProductCheckoutStep_3", ids.join("_"));

	} catch(e) {
		console.error(e)
	}
}

//get cookie val by name
function getCookie(name) {
	var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
	if(arr = document.cookie.match(reg)) {
		return unescape(arr[2]);
	} else {
		return null;
	}
}

function checkout_monitor(cart) {
	var ids = []
	for(var i = 0; i < cart.length; i++) {
		var product = cart[i];
		ids.push(product.id);
		ga('ec:addProduct', {
			'id': product.id,
			'name': product.name,
			'price': product.price,
			'quantity': product.qty
		});
	}
	return ids;
}

//获取sku, 主品, 赠品, 服务
function parseSku(sku, cart, ids) {
	ids.push(sku.id);
	cart.push({
		id: sku.id,
		name: sku.name,
		price: sku.price,
		qty: sku.num
	});

	var gifts = sku.gifts;
	if(gifts) {
		for(var i = 0; i < gifts.length; i++) {
			var sku = gifts[i];
			ids.push(sku.id);
			cart.push({
				id: sku.id,
				name: sku.name,
				price: 0,
				qty: sku.num
			});
		}
	}

	var services = sku.services;
	if(services) {
		for(var i = 0; i < services.length; i++) {
			var sku = services[i];
			ids.push(sku.id);
			cart.push({
				id: sku.id,
				name: sku.name,
				price: sku.price,
				qty: sku.num
			});
		}
	}
}

//更新缓存并checkout
function usevirtualcurrency(updateItem, content) {
	var ajaxData;
	if(updateItem == UpdateBackFillItem.COUPONIDS) {
		var arr = [];
		for(var i = 0; i < couponidTempArr.length; i++) {
			if(content.indexOf(couponidTempArr[i]) != -1) {
				arr.push(couponidTempArr[i]);
			}
		}
		ajaxData = arr.join(",");
	} else {
		ajaxData = content;
	}

	$.post(buy_order.URL.usevirtualcurrency(), {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		virtualType: updateItem,
		content: ajaxData,
		ss: new Date().getTime()
	}, function(data) {
		if(data != null) {
			if(data.rc != 0) {
				//                         if(updateItem==UpdateBackFillItem.COUPONIDS){
				//                             $("#isSuccessful").val(0);
				//                         }
				//showMessage(3000,data.msg);
				if(data.rc == 10014 || data.rc == 20101 || data.rc == 10010) {
					window.location.href = buy_order.URL.getcart();
				} else {
					showMessage(3000, data.msg);
				}
				cleanInput(updateItem, 1);
				if(updateItem == UpdateBackFillItem.COUPONIDS) {
					// var selectedCoupon = $("#selectedCoupon").val();
					var selectedCoupon = content.split(",").pop();
					if(selectedCoupon) {
						couponidArr.remove(selectedCoupon);
						$("#" + selectedCoupon).removeClass("pinks");
						$("#selectedCoupon").val("");
						var count = 0;
						var totalMoney = 0;
						$("#tab_01 .bgses").each(function(i, n) {
							var obj = $(n);
							if(obj.hasClass("pinks")) {
								var id = obj.attr("id");
								count++;
								var at = $("#" + id + " p").eq(0).html();
								totalMoney += parseInt(at);
							}
						});
						updateCouponids();
						$("#sy").html(count);
						$("#zj").html(totalMoney);
					}
				}
				return;
			} else {
				if(updateItem == UpdateBackFillItem.COUPONIDS) {
					if(data.msg && data.msg != "success") {
						showMessage(2000, data.msg);
					}
				}
			}
			var temp = data.data.checkOutOrder; //渲染
			var order = data.data.bfOrderVo; //回显
			if(temp != null) {
				renderPage(temp, order, updateItem);
			}
		}
	}, 'json');
}

/*渲染地址*/
function showConsignList(data, order, addresstype) {
	var addHtml = '';
	var _this = $("#box-a");
	if(addresstype == AddressTypeEnums.DONGDE || addresstype == AddressTypeEnums.SH) {
		addHtml = '<p>' + orderResource.delivery_info + '：<span class="showbtn-' + addresstype + ' showbtn new_p" latag="latag_pc_ordersubmit_newaddress" onclick="showAdd(\'' + addresstype + '\')"><span  style="cursor:pointer;">＋' + orderResource.add_delivery_address + '</span></span></p><div id="addressList-' + addresstype + '">  <input type="hidden" id="chooseid-' + addresstype + '"> </div>';
		_this = $("#box-a");
	} else if(addresstype == AddressTypeEnums.SP) {
		var isAddress = '';
		if(shopId == 8) {
			isAddress = '<span><input type="checkbox" id="invoice-cb" onclick="invoiceIsConsignee()" />' + orderResource.same_as_delivery_address + '</span>';
		}
		addHtml = '<p class="address—p line50">' + orderResource.invoice_delivery_address + '：' + isAddress + '<span class="showbtn-' + addresstype + ' showbtn new_p" latag="latag_pc_ordersubmit_newaddress" onclick="showAdd(\'' + addresstype + '\')"><span style="cursor:pointer;">＋' + orderResource.add_invoice_delivery_address + '</span></span></p> <div id="addressList-' + addresstype + '"> <input type="hidden" id="chooseid-' + addresstype + '"></div> ';
		_this = $("#box-d");
	} else if(addresstype == AddressTypeEnums.HT) {
		addHtml = '<p class="address—p line50">' + orderResource.contract_delivery_address + '：<span><input type="checkbox" id="contract-send" onclick="isSendContract()"/>' + orderResource.whether_deliver_contract + '</span></p><div class="line50" id="contract-is" style="display: none"><input style="margin-left:102px" type="checkbox" id="contract-cb" onclick="contractIsConsignee()"/>' + orderResource.same_as_delivery_address + '</span><span class="showbtn-' + addresstype + ' showbtn new_p" latag="latag_pc_ordersubmit_newaddress" onclick="showAdd(\'' + addresstype + '\')"><span style="cursor:pointer;">＋' + orderResource.add_contract_delivery_address + '</span></span><div id="addressList-' + addresstype + '"> <input type="hidden" id="chooseid-' + addresstype + '"></div></div> ';
		_this = $("#box-e");
	}
	_this.empty();
	_this.append(addHtml);
	var more_address = '<div class="address_div" onclick="showAddress(\'addressList-' + addresstype + '\')">' +
		'<a href="javascript:" class="more_address"><img src="' + pcImgHomeModule + '/base/update_down.jpg" class="update_ico" /><span class="update_address">' + orderResource.more_delivery_address + '</span></a>' +
		'</div>';
	if(data.length < 2) {
		$.each(data, function(i, item) {
			item.isdefault = "1";
			$("#addressList-" + addresstype).append(getAddressItem(item, addresstype, true));
			$("#addressList-" + addresstype).append(more_address);
		})
	} else {
		$.each(data, function(i, item) {
			if(i == 0) {
				$("#addressList-" + addresstype).append(getAddressItem(item, addresstype, true));
			} else if(i == 1) {
				$("#addressList-" + addresstype).append('<div class="update_item">' + getAddressItem(item, addresstype, false) + '</div>');
			} else {
				$("#addressList-" + addresstype).find(".update_item").append(getAddressItem(item, addresstype, false));
			}
		})
		$("#addressList-" + addresstype).append(more_address);
	}

	/*new address page*/
	_this.append(getNewAddressStr(addresstype));
	_this.append('<input type="hidden" id="pre_phone">');
	if(order) {
		$(".address-" + addresstype).removeClass("pink");
		$("#bgdiv" + order).addClass("pink");
		$("#chooseid-" + addresstype).val(order);

		if(!getCheckEmpty($("#addressList-" + addresstype + ">input").val()) && !getCheckEmpty($("#addressList-" + addresstype + ">div:first").attr("id")) && $("#addressList-" + addresstype + ">div:first").attr("id") != ("#bgdiv" + $("#addressList-" + addresstype + ">input").val())) {
			$("#addressList-" + addresstype + " .update_item>div:first").before($("#addressList-" + addresstype + ">div:first"));
			$("#addressList-" + addresstype + ">input").after($("#bgdiv" + $("#addressList-" + addresstype + ">input").val()));
		}
	}
}

function invoiceIsConsignee() {
	var ajaxdata = {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItems: [UpdateBackFillItem.INVOICEADDRESS, UpdateBackFillItem.INVOICEISCONSIGNEE],
		invoiceIsConsigneeId: "0",
		invoiceAddressId: ""
	}
	if($("#invoice-cb").is(":checked")) {
		ajaxdata.invoiceIsConsigneeId = "1";
	} else {
		ajaxdata.invoiceIsConsigneeId = "0";
	}
	updateCheckOutCacheList(ajaxdata, AddressTypeEnums.SP);
}

function contractIsConsignee() {
	var ajaxdata = {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItems: [UpdateBackFillItem.CONTRACTADDRESS, UpdateBackFillItem.CONTRACTISCONSIGNEE, UpdateBackFillItem.ISSENDCONTRACT],
		contractIsConsigneeId: "0",
		contractAddressId: "",
		isSendContract: "1"
	}
	if($("#contract-cb").is(":checked")) {
		ajaxdata.contractIsConsigneeId = "1";
	} else {
		ajaxdata.contractIsConsigneeId = "0";
	}
	updateCheckOutCacheList(ajaxdata, AddressTypeEnums.HT);
}

function isSendContract() {
	var ajaxdata = {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItems: [UpdateBackFillItem.CONTRACTADDRESS, UpdateBackFillItem.CONTRACTISCONSIGNEE, UpdateBackFillItem.ISSENDCONTRACT],
		contractIsConsigneeId: "0",
		contractAddressId: "",
		isSendContract: "1"
	}
	if($("#contract-send").is(":checked")) {
		ajaxdata.isSendContract = "1";
	} else {
		ajaxdata.isSendContract = "0";
	}
	updateCheckOutCacheList(ajaxdata, AddressTypeEnums.HT);
}

function getAddressItem(item, addresstype, isDefault) {
	var areanos = addresstype == AddressTypeEnums.DONGDE ? item.areaNos : "";
	var townshipCode = getCheckEmpty(item.townshipCode) ? '' : item.townshipCode;
	var longAddress = item.provinceCode + item.cityCode + item.countyCode + item.address;
	if(addresstype == AddressTypeEnums.SH && (shopId == 8 || shopId == 9 || shopId == 1 || shopId == 3) || (shopId == 1 || shopId == 3) && addresstype == AddressTypeEnums.SP) {
		longAddress = item.provinceCode + item.cityCode + item.countyCode + townshipCode + item.address;
	}
	if(longAddress.length > 25) {
		longAddress = longAddress.substring(0, 24) + "..."
	}
	var defaultSpan = '';
	var pink = '';
	if(item.isdefault == 1) {
		$("#chooseid-" + addresstype).val(item.id);
		defaultSpan = '<span>' + orderResource.default_delivery_address + '</span>';
		pink = 'pink';
	} else if(isDefault) {
		$("#chooseid-" + addresstype).val(item.id);
		pink = 'pink';
	}
	var telMobile = "";
	var phone = "";
	if(!getCheckEmpty(item.mobile)) {
		telMobile = hiddenMobile(item.mobile);

		phone = item.mobile;
	} else if(!getCheckEmpty(item.tel)) {
		telMobile = hiddenMobile(item.tel);
		//phone = item.tel;
	}
	var modify = "";
	if(shopId != 14) {
		modify = '<span class="red showbtn" latag="latag_pc_ordersubmit_editaddress" onclick="updateAddress(\'' + item.townshipCode + '\',\'' + item.company + '\',\'' + item.zip + '\',\'' + item.id + '\',\'' + item.name + '\',\'' + item.mobile + '\',\'' + item.provinceCode + '\',\'' + item.cityCode + '\',\'' + item.countyCode + '\',\'' + item.address + '\',\'' + item.email + '\',\'' + item.isdefault + '\',\'' + item.tel + '\',\'' + areanos + '\',\'' + addresstype + '\', event)">' + orderResource.modify + '</span>';
	}
	return '<div class="box-ax bgse  address-' + addresstype + ' ' + pink + '"  id="bgdiv' + item.id + '" latag="latag_pc_ordersubmit_address" onclick="chooseAddress(\'' + item.id + '\',\'' + addresstype + '\')">' +
		'<input type="hidden" id="pre_phone" value="' + phone + '">' +
		'<p style="width:190px">' + item.name + '</p>' +
		'<p style="width:140px" id="pre_tel">' + telMobile + '</p>' +
		'<p style="width:500px">' + longAddress + '</p>' +
		' <p class="ax-sp">' + defaultSpan + modify + '<a href="javascript:void(0)" onclick="deleteAddress_(\'' + item.id + '\',\'' + addresstype + '\', event)">╳</a></p>';
	'<img id="icon" src="' + pcImgHomeModule + '/base/pic-07.jpg' + '" id="icon"> </div>';

}

function showAddress(_this) {

	if(!getCheckEmpty($("#" + _this + ">input").val()) && !getCheckEmpty($("#" + _this + ">div:first").attr("id")) && $("#" + _this + ">div:first").attr("id") != ("#bgdiv" + $("#" + _this + ">input").val())) {
		$("#" + _this + " .update_item>div:first").before($("#" + _this + ">div:first"));
		$("#" + _this + ">input").after($("#bgdiv" + $("#" + _this + ">input").val()));
	}

	var ele = $(_this).parent().attr("id");
	if($("#" + _this + ' .update_item').css("display") == "none") {
		$("#" + _this + ' .update_item').show();
		$("#" + _this + ' .update_ico').attr('src', pcImgHomeModule + '/base/update_up.jpg');
		$("#" + _this + ' .update_address').html(orderResource.collapse_address);
	} else {
		$("#" + _this + ' .update_item').hide();
		$("#" + _this + ' .update_ico').attr('src', pcImgHomeModule + '/base/update_down.jpg');
		$("#" + _this + ' .update_address').html(orderResource.more_delivery_address);
	}
}

/*new  address page*/
function getNewAddressStr(addresstype) {
	var zipStr = '<li>' +
		'<label><span>* </span>' + orderResource.postal_code + '：</label>' +
		'<input type="text"  id="zip-' + addresstype + '">' +
		'</li>';
	var companyStr = '';
	var mailPrompt = orderResource.use_for_receive_email;
	if(shopId == 8 || shopId == 9) {
		zipStr = '<li>' +
			'<label><span>* </span>' + orderResource.postal_code + '：</label>' +
			'<input type="text"  id="zip-' + addresstype + '" readonly>' +
			'</li>';
		companyStr = '<li>' +
			'<label><span>* </span>' + orderResource.receiver_company + '：</label>' +
			'<input type="text" id="company-' + addresstype + '">' +
			'</li>';
	}

	if(addresstype == AddressTypeEnums.SH) {
		var villageStr = '';
		if(shopId == 8 || shopId == 9 || shopId == 1 || shopId == 3) {
			villageStr = '<select id="goodsCounty-' + addresstype + '" name="goodsCounty-' + addresstype + '" onChange="getVillages(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.county + '</option>' +
				'</select>' +
				'<select id="goodsVillage-' + addresstype + '" name="goodsVillage-' + addresstype + '" style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.village + '</option>' +
				'</select>';
			mailPrompt = "";
			if(shopId == 1 || shopId == 3) {
				zipStr = '';
			}
		} else {
			villageStr = '<select id="goodsCounty-' + addresstype + '" name="goodsCounty-' + addresstype + '"  style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.county + '</option>' +
				'</select>';
			zipStr = '';
		}
		return '<div id="bg-' + addresstype + '" class="bg-n"></div>' +
			'<div style="display:none" class="box-' + addresstype + ' box">' +
			'<input type="hidden" id="flag1-' + addresstype + '" value="0">' +
			'<input type="hidden" id="deliveridupdate-' + addresstype + '" value="">' +
			'<a class="close" href="javascript:void(0);" latag="latag_pc_ordersubmit_address_closealert" onclick="closeAlert(\'' + addresstype + '\')">╳</a>' +
			'<ul>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.receiver + '：</label>' +
			'<input type="text" id="name-' + addresstype + '" ><label id="alertName-' + addresstype + '" style="display:none;color:red">' + orderResource.receiver_is_required + '</label>' +
			'</li>' + companyStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.mobile_phone + '：</label>' +
			'<input type="text" id="mobile-' + addresstype + '">' +
			'<label>  ' + orderResource.telephone + '：</label>' +
			'<input type="text"  id="phone-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.address + '：</label>' +
			'<select id="goodsProvince-' + addresstype + '" name="goodsProvince-' + addresstype + '" onChange="getCities(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.province + '</option>' +
			'</select>' +
			'<select id="goodsCity-' + addresstype + '" name="goodsCity-' + addresstype + '" onChange="getCounties(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.city + '</option> ' +
			'</select>' + villageStr +
			'</li>' + zipStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.address_detail + '：</label>' +
			'<input type="text" style="width:410px;" id="goodsStreet-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label>' + orderResource.email + '：</label>' +
			'<input type="text" id="mail-' + addresstype + '">' +
			'<span style="color:red;vertical-align: middle;padding-left: 5px;">' + mailPrompt + '</span>' +
			'</li>' +
			'<li>' +
			'<label><input type="checkbox" style="width:14px;height:14px;margin-top: -8px;" id="isCheck-' + addresstype + '" latag="latag_pc_ordersubmit_address_defaultcheck">&nbsp;&nbsp;</label>' +
			orderResource.set_as_default_delivery_address +
			'</li>' +
			'<li>' +
			'<label></label>' +
			'<button id="submitbtn-' + addresstype + '" onclick="submitInfo(\'' + addresstype + '\')" latag="latag_pc_ordersubmit_address_confirm">' + orderResource.save_receiver_info + '</button>' +
			'</li>' +
			'</ul>' +
			'</div>';
	} else if(addresstype == AddressTypeEnums.SP) {
		var villageStr = '';
		if(shopId == 1 || shopId == 3) {
			villageStr = '<select id="goodsCounty-' + addresstype + '" name="goodsCounty-' + addresstype + '" onChange="getVillages(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.county + '</option>' +
				'</select>' +
				'<select id="goodsVillage-' + addresstype + '" name="goodsVillage-' + addresstype + '" style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.village + '</option>' +
				'</select>';
		} else {
			villageStr = '<select id="goodsCounty-' + addresstype + '" name="goodsCounty-' + addresstype + '"  style=" height:25px;width:120px">' +
				'<option value="">' + orderResource.county + '</option>' +
				'</select>';
		}
		return '<div id="bg-' + addresstype + '" class="bg-n"></div>' +
			'<div style="display:none" class="box-' + addresstype + ' box">' +
			'<input type="hidden" id="flag1-' + addresstype + '" value="0">' +
			'<input type="hidden" id="deliveridupdate-' + addresstype + '" value="">' +
			'<a class="close" href="javascript:void(0);" latag="latag_pc_ordersubmit_address_closealert" onclick="closeAlert(\'' + addresstype + '\')">╳</a>' +
			'<ul>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.receiver + '：</label>' +
			'<input type="text" id="name-' + addresstype + '" >' +
			'</li>' + companyStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.mobile_phone + '：</label>' +
			'<input type="text" id="mobile-' + addresstype + '">' +
			'<label>  ' + orderResource.telephone + '：</label>' +
			'<input type="text"  id="phone-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.address + '：</label>' +
			'<select id="goodsProvince-' + addresstype + '" name="goodsProvince-' + addresstype + '" onChange="getCities(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.province + '</option>' +
			'</select>' +
			'<select id="goodsCity-' + addresstype + '" name="goodsCity-' + addresstype + '" onChange="getCounties(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.city + '</option> ' +
			'</select>' + villageStr +

			'</li>' +

			'<li>' + zipStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.address_detail + '：</label>' +
			'<input type="text" style="width:410px;" id="goodsStreet-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label>' + orderResource.email + '：</label>' +
			'<input type="text" id="mail-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><input type="checkbox" style="width:14px;height:14px;margin-top: -8px;" id="isCheck-' + addresstype + '" latag="latag_pc_ordersubmit_address_defaultcheck">&nbsp;&nbsp;</label>' +
			orderResource.set_as_default_delivery_address +
			'</li>' +
			'<li style="padding-left: 50px;line-height: 13px;" >' +
			'<p>' + orderResource.reminder_p1 + '</p></br>' +
			'<p>' + orderResource.reminder_p2 + '</p></br>' +
			'<p>' + orderResource.reminder_p3 + '</p></br>' +
			'</li>' +
			'<li>' +
			'<label></label>' +
			'<button id="submitbtn-' + addresstype + '" onclick="submitInfo(\'' + addresstype + '\')" latag="latag_pc_ordersubmit_address_confirm">' + orderResource.save_receiver_info + '</button>' +
			'</li>' +
			'</ul>' +
			'</div>';
	} else if(addresstype == AddressTypeEnums.DONGDE) {
		return '<div id="bg-' + addresstype + '" class="bg-n"></div>' +
			'<div style="display:none" class="box-' + addresstype + ' box">' +
			'<input type="hidden" id="flag1-' + addresstype + '" value="0">' +
			'<input type="hidden" id="deliveridupdate-' + addresstype + '" value="">' +
			'<a class="close" href="javascript:void(0);" latag="latag_pc_ordersubmit_address_closealert" onclick="closeAlert(\'' + addresstype + '\')">╳</a>' +
			'<ul>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.receiver + '：</label>' +
			'<input type="text" id="name-' + addresstype + '" >' +
			'<span style="color: #A79F9F;vertical-align: middle;padding-left: 5px;">' + orderResource.name_same_as_ID_card + '</span>' +
			'<label id="alertName-' + addresstype + '" style="display:none;color:red;width: 100px;">' + orderResource.receiver_is_required + '</label>' +
			'</li>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.mobile_phone + '：</label>' +
			'<input type="text" id="mobile-' + addresstype + '">' +
			'<label>  ' + orderResource.telephone + '：</label>' +
			'<input type="text"  id="phone-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.address + '：</label>' +
			'<select id="s_province" name="s_province"  style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.province + '</option>' +
			'</select>' +
			'<select id="s_city" name="s_city"  style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.city + '</option> ' +
			'</select>' +
			'<select id="s_county" name="s_county" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.county + '</option>' +
			'</select>' +
			'</li>' +
			' <script type="text/javascript">' +
			'  _init_area();' +
			'</script>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.address_detail + '：</label>' +
			'<input type="text" style="width:410px;" id="goodsStreet-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label>' + orderResource.email + '：</label>' +
			'<input type="text" id="mail-' + addresstype + '">' +
			'<span style="color:red;vertical-align: middle;padding-left: 5px;">' + orderResource.use_for_receive_email + '</span>' +
			'</li>' +
			'<li>' +
			'<label><input type="checkbox" style="width:14px;height:14px;margin-top: -8px;" id="isCheck-' + addresstype + '" latag="latag_pc_ordersubmit_address_defaultcheck">&nbsp;&nbsp;</label>' +
			orderResource.set_as_default_delivery_address +
			'</li>' +
			'<li>' +
			'<label></label>' +
			'<button id="submitbtn-' + addresstype + '" onclick="submitInfo(\'' + addresstype + '\')" latag="latag_pc_ordersubmit_address_confirm">' + orderResource.save_receiver_info + '</button>' +
			'</li>' +
			'</ul>' +
			'</div>';
	} else if(addresstype == AddressTypeEnums.HT) {
		return '<div id="bg-' + addresstype + '" class="bg-n"></div>' +
			'<div style="display:none" class="box-' + addresstype + ' box">' +
			'<input type="hidden" id="flag1-' + addresstype + '" value="0">' +
			'<input type="hidden" id="deliveridupdate-' + addresstype + '" value="">' +
			'<a class="close" href="javascript:void(0);" latag="latag_pc_ordersubmit_address_closealert" onclick="closeAlert(\'' + addresstype + '\')">╳</a>' +
			'<ul>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.receiver + '：</label>' +
			'<input type="text" id="name-' + addresstype + '" >' +
			'</li>' + companyStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.mobile_phone + '：</label>' +
			'<input type="text" id="mobile-' + addresstype + '">' +
			'<label>  ' + orderResource.telephone + '：</label>' +
			'<input type="text"  id="phone-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><span>* </span>' + orderResource.address + '：</label>' +
			'<select id="goodsProvince-' + addresstype + '" name="goodsProvince-' + addresstype + '" onChange="getCities(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.province + '</option>' +
			'</select>' +
			'<select id="goodsCity-' + addresstype + '" name="goodsCity-' + addresstype + '" onChange="getCounties(\'' + addresstype + '\')" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.city + '</option> ' +
			'</select>' +
			'<select id="goodsCounty-' + addresstype + '" name="goodsCounty-' + addresstype + '" style=" height:25px;width:120px">' +
			'<option value="">' + orderResource.county + '</option>' +
			'</select>' +
			'</li>' + zipStr +
			'<li>' +
			'<label><span>* </span>' + orderResource.address_detail + '：</label>' +
			'<input type="text" style="width:410px;" id="goodsStreet-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label>' + orderResource.email + '：</label>' +
			'<input type="text" id="mail-' + addresstype + '">' +
			'</li>' +
			'<li>' +
			'<label><input type="checkbox" style="width:14px;height:14px;margin-top: -8px;" id="isCheck-' + addresstype + '" latag="latag_pc_ordersubmit_address_defaultcheck">&nbsp;&nbsp;</label>' +
			orderResource.set_as_default_delivery_address +
			'</li>' +
			'<li>' +
			'<label></label>' +
			'<button id="submitbtn-' + addresstype + '" onclick="submitInfo(\'' + addresstype + '\')" latag="latag_pc_ordersubmit_address_confirm">' + orderResource.save_receiver_info + '</button>' +
			'</li>' +
			'</ul>' +
			'</div>';
	} else {
		return "";
	}

}

//渲染支付方式
function showPayType(data, order, obj, orderObj) {
	var flag = false;
	$("#box-b").empty();
	if(obj.checkoutType == "presell") {
		flag = true;
	}
	if(data != null && data != "") {
		var paytypeStr = '<p>' + orderResource.payment_way + '：</p>';
		if(shopId == 8) {
			paytypeStr = '<p>' + orderResource.payment_way + '&nbsp;<span class="zffs_red">(' + orderResource.invoice_content_just_support_detail + ')</span>：</p>'
		}
		for(var i = 0; i < data.length; i++) {
			paytypeStr += ' <div style="cursor:pointer;" class="box-ax bgse" latag="latag_pc_ordersubmit_payonline" onclick="choosePay(' + data[i].type + ')" id="bgdiv' + data[i].type + '" value="' + data[i].type + '" >' +
				' <p><span>' + data[i].name + '</span></p>' +
				' <img src="' + pcImgHomeModule + '/base/pic-07.jpg' + '" id="icon">' +
				' </div>';
		}
		if(flag) {
			var preTel;
			if(orderObj.presellTel) {
				preTel = hiddenMobile(orderObj.presellTel);
				$("#pre_phone").val(orderObj.presellTel);
			} else {
				preTel = $("#pre_tel").html();
			}
			if(preTel == undefined) {
				preTel = "";
			}
			var telHtml = "<div style='font-size: 14px;color: #635f5a;padding-top: 10px;'><img style='width: 30px;margin-left: 10px;margin-top: -5px;' src='" + pcImgHomeModule + "/base/warn.png'>" + orderResource.remain_pay_contact + ":<span id='thisPreTel'>" + preTel + "<input type='button' id='submitTel' onclick='changeTel()' value='" + orderResource.modify + "'/></span></div>";
			paytypeStr += telHtml;
			var $presell = $("#presell_condition");
			if($presell != 'undefined') {
				$presell.remove();
			}
			$("#agree_condition").append("<span id='presell_condition'><a href='turnPresell.jhtm' class='blink' target='_blank' latag='latag_pc_odersubmit_turnb2c'>&   " + orderResource.pre_sale_agreement + "</a></span>"); // TODO 预售协议连接
		}
		paytypeStr += "<input id='presellflag' type='hidden' value='" + flag + "'/>";
		$("#box-b").append(paytypeStr);
		if(order != null && order != "") {
			$("#bgdiv" + order).addClass("pink").siblings().removeClass("pink");
		} else {
			$("#bgdiv" + data[0].type).addClass("pink").siblings().removeClass("pink");
		}
	}
	//updatePayType();
}

function changeTel() {
	var text = $("#pre_phone").val();
	if(text == undefined) {
		text = "";
	}
	var html = "<input type='text' id='textTel' value='" + text + "'/><input type='button' value='" + orderResource.confirm + "' onclick='confirmTel()'/>";
	$("#thisPreTel").html(html);
}

function confirmTel() {
	var preTel = $("#textTel").val();
	if(!check_mobile(preTel)) {
		showMessage(3000, orderResource.input_remain_pay_contact_phone);
		$("#textTel").val("");
		$("#pre_phone").val("");
		return;
	}
	var newPreTel = hiddenMobile(preTel);
	var telHtml = newPreTel + "<input type='button' id='submitTel' onclick='changeTel()' value='" + orderResource.modify + "'/>";
	$("#pre_phone").val(preTel);
	$("#thisPreTel").html(telHtml);
	updatePresellTel(preTel);
}

var creditInfo = ""; //信用额度字符串  facode|100@facode|200
function useCredit(obj) {
	//avaliable_
	//var creditNum = 0;
	// $(".usecredit").each(function(){
	//     var id = "input_" + $(this).attr("id").split("_");
	//     var input = $("#"+id);
	//     if($(obj).is(':checked') || !isNaN(input.val())){
	//         creditInfo += $("#"+id).attr("faCode")+"|"+input.val()+"@";
	//     }
	// });
	// if(creditInfo.length>0){
	//     creditInfo.substring(0,creditInfo.length - 1);
	//     updateCheckOutCache(UpdateBackFillItem.CREDITINFO,creditInfo);
	// }

}
//渲染购物清单
function showCartList(data, order, buyType, temp, tempAll) {
	showProduct(data, order, buyType, temp, tempAll);
}

function showProduct(data, order, buyType, temp, tempAll) {
	if(!getCheckEmpty(data.mainSkus[0]) && data.mainSkus[0].salesType === 98) { //o2o
		iso2o = true;
	}
	if(!getCheckEmpty(data.mainSkus[0]) && data.mainSkus[0].salesType === 2) {
		isPreSale = true;
	}
	if(!getCheckEmpty(data.mainSkus[0]) && data.mainSkus[0].salesType === 96) {
		iscto = true;
	}
	if(!getCheckEmpty(data.mainSkus[0]) && data.mainSkus[0].salesType === 97) {
		isCrowdunding = true;
	}
	$("#cto_personal").hide();
	$("#productList").empty();
	var moneyShow = orderResource.amount_of_money;
	if(shopId == 9) {
		moneyShow = orderResource.point;
	}
	var back = '';
	if(buyType == 0) {
		back = '<a href="getcart.jhtm" latag="latag_pc_ordersubmit_backtocart">' + orderResource.back_to_cart + '></a>';
	}

	var productHeader = '';
	if(tempAll.checkoutType == "consumer_score") {
		productHeader = '<div class="box-tl"><p>' + back + orderResource.confirmed_goods + '&nbsp' + '&nbsp' + '<span style="font-family:微软雅黑;font-size: 12px;line-height: 50px;color: red" id="consumer_score">(积分兑换商品不支持7天无理由退换货)</span>' + '</p></div><div class="box-ls" style="margin-bottom: -20px;"><p class="tl-a">&nbsp;</p><p class="tl-b">' + orderResource.goods_name + '</p><p class="tl-c">' + orderResource.price + '</p><p class="tl-d">' + orderResource.num + '</p><p class="tl-e">' + moneyShow + '</p></div>';
	} else {
		productHeader = '<div class="box-tl"><p>' + back + orderResource.confirmed_goods + '&nbsp' + '&nbsp' + '<span style="font-family:微软雅黑;font-size: 12px;line-height: 50px;color: red">(定制类产品，' + ((iso2o || isPreSale || iscto || isCrowdunding) ? '手机产品激活后、' : '') + '虚拟产品不支持7天无理由退换货)</span>' + '</p></div><div class="box-ls" style="margin-bottom: -20px;"><p class="tl-a">&nbsp;</p><p class="tl-b">' + orderResource.goods_name + '</p><p class="tl-c">' + orderResource.price + '</p><p class="tl-d">' + orderResource.num + '</p><p class="tl-e">' + moneyShow + '</p></div>';
	}
	/*
	    var productHeader = '<div class="box-tl"><p>'+back+orderResource.confirmed_goods+'&nbsp'+'<span style="font-family: “微软雅黑”;font-size: 12px;line-height: 50px;color: red" id="consumer_score">(积分兑换商品不支持7天无理由退换货)</span>'+ '</p></div><div class="box-ls" style="margin-bottom: -20px;"><p class="tl-a">&nbsp;</p><p class="tl-b">'+orderResource.goods_name+'</p><p class="tl-c">'+orderResource.price+'</p><p class="tl-d">'+orderResource.num+'</p><p class="tl-e">' + moneyShow + '</p></div>';
	*/
	$("#productList").append(productHeader);
	var productList = data.vendors;
	// console.log(productList);
	products_c = data.vendors;
	var $invoiceFaid = "";
	var $invoiceFaType = "";
	if($("#invoice_faid").length == 0) {
		$invoiceFaid = $("#invoice_faid").val();
		if($("#invoice_fatype").length == 0) {
			$invoiceFaType = $("#invoice_fatype").val();
		}
	} else {
		$("#productList").append("<input type='hidden' id='invoice_faid'/>");
		$invoiceFaid = "";
		$("#productList").append("<input type='hidden' id='invoice_fatype'/>");
		$invoiceFaType = "";
	}
	$("#productList").addClass("usecredit");
	for(var i = 0; i < productList.length; i++) {
		if(getCheckEmpty($invoiceFaid) || $invoiceFaid.length < 10) {
			$("#invoice_faid").val(productList[i].id);
			$("#invoice_fatype").val(productList[i].type);
		}
		var sortedList = productList[i].sorted;
		for(var j = 0; j < sortedList.length; j++) {
			if(sortedList[j].itemType == 0 || sortedList[j].itemType == 5) {
				if(sortedList[j].item.salesType == 96) {
					if(shopId == 9) {
						var money = sortedList[j].item.num * sortedList[j].item.price;
					} else {
						var money = (sortedList[j].item.num * sortedList[j].item.price).toFixed(2);
					}

					if(null == sortedList[j].item.gspecStr || sortedList[j].item.gspecStr == "null") {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="javascript:;"><img src="' +
							changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="javascript:;">' + sortedList[j].item.name +
							'</a><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
							'</p><p class="list-e">' + money + '</p>';
						$("#productList").append(mainHtml);

					} else {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="javascript:;"><img src="' +
							changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="javascript:;">' + sortedList[j].item.name + '&nbsp;[' +
							sortedList[j].item.gspecStr + ']</a><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
							'</p><p class="list-e">' + money + '</p>';
						$("#productList").append(mainHtml);
					}

					//old cto
					var itemArr = [];
					if(sortedList[j].item.attributes.cto != null) {
						var cto = sortedList[j].item.attributes.cto;
						//个性化配置信息
						var personalStr = '';
						var cvItemlength = cto.cvlist.cvItemList.length;
						for(var m = 0; m < cvItemlength; m++) {
							if(cto.cvlist.cvItemList[m].isselect == "1") {
								itemArr.push(cto.cvlist.cvItemList[m]);
							}
						}
						for(var h = 0; h < itemArr.length; h = h + 2) {
							if((h + 1) == itemArr.length) {
								personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%"></td> <td width="35%"></td> </tr>';
							} else {
								personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%">' + itemArr[h + 1].char_des + '</td> <td width="35%">' + itemArr[h + 1].charvalue_des + '</td> </tr>';
							}
						}
						$(".config_table").empty().append(personalStr);

						var custom_p = eval('(' + cto.lenovoMakerPart.custom + ')');
						//包含 图 显示
						if(custom_p.personalization.pageA.imageUrl) {
							var pagea_img = '<span class="span_top">' + orderResource.demonstrate + ':</span><img class="personal_img" src="' + changeImgSize(custom_p.personalization.pageA.imageUrl, 80) + '" alt="">';
							$("#personal_imga").empty().append(pagea_img);
						} else {
							//隐藏A面图
							$(".dsix_boxg_cont").eq(1).hide();
						}

						//C面刻字
						var customLaser = cto.lenovoMakerPart.customLaserPreviewDTO.customLaser;
						if(customLaser) {
							customLaser = '<b>' + customLaser + '</b>';
						} else {
							customLaser = "";
						}
						var pagec_char = '<ul class="left"><li><span>' + orderResource.words + '：</span>' + customLaser + ' </li>  </ul>';

						$("#pagec_char").empty().append(pagec_char);
						if(cto.lenovoMakerPart.customTextPreviewDTO.fontColor) {
							$(cto.lenovoMakerPart.customTextPreviewDTO.fontColor.value).append('<img src="http://lenovopic.app.lefile.cn/icon/selected.png">');
						}
						if(itemArr.length > 0) {
							$("#cto_personal").show();
						}

					} else if(sortedList[j].item.attributes.thinkcto != null || sortedList[j].item.attributes.fakethinkcto != null) {
						//thinkcto
						var thinkcto = sortedList[j].item.attributes.thinkcto;
						if(!thinkcto) {
							thinkcto = sortedList[j].item.attributes.fakethinkcto
						}

						var personalStr = '';
						var cvItemlength = thinkcto.cvItemList.length;
						for(var m = 0; m < cvItemlength; m++) {
							if(thinkcto.cvItemList[m].isselect == "1") {
								itemArr.push(thinkcto.cvItemList[m]);
							}
						}
						for(var h = 0; h < itemArr.length; h = h + 2) {
							if((h + 1) == itemArr.length) {
								personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%"></td> <td width="35%"></td> </tr>';
							} else {
								personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%">' + itemArr[h + 1].char_des + '</td> <td width="35%">' + itemArr[h + 1].charvalue_des + '</td> </tr>';
							}
						}

						$(".config_table").empty().append(personalStr);
						$(".dsix_boxg_cont").eq(1).hide();
						$(".dsix_boxg_cont").eq(2).hide();
						if(itemArr.length > 0) {
							$("#cto_personal").show();
						}

					} else {
						$(".dsix_boxg_cont").eq(1).hide();
						$(".dsix_boxg_cont").eq(2).hide();
						if(itemArr.length > 0) {
							$("#cto_personal").show();
						}
					}

					//暂时发现私人订制没有显示服务，20180125
					if(sortedList[j].item.services.length != 0) {
						$("#" + sortedList[j].item.id).css("border-bottom", "none");
						for(var k = 0; k < sortedList[j].item.services.length; k++) {
							var money = (sortedList[j].item.services[k].num * sortedList[j].item.services[k].price).toFixed(2);
							var serviceHtml = '<div class="box-ltx"><p class="list-aa">' + orderResource.service + '：' + sortedList[j].item.services[k].name + '</p><p class="list-c">' +
								sortedList[j].item.services[k].price + '</p><p class="list-d">' + sortedList[j].item.services[k].num + '</p><p class="list-e">' + money + '</p></div>';

							$("#productList").append(serviceHtml);
						}
					}

					//私人订制
					if(null != sortedList[j].item.attributes.personalization && eval('(' + sortedList[j].item.attributes.personalization + ')').length > 0) {
						$("#dzagree").css("display", "block");
						var personNum = sortedList[j].item.num;
						var persons = eval('(' + sortedList[j].item.attributes.personalization + ')');
						for(var k = 0; k < persons.length; k++) {
							$("#" + sortedList[j].item.id).css("border-bottom", "none");
							var person = persons[k];
							var totalPrice = (personNum * parseFloat(person.price)).toFixed(2);
							if(person.ptmode == "1") {
								var ptType = person.pttype == "1" ? orderResource.spray_printing : orderResource.radium_carve;
								var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title" style="font-weight:bold;margin-left:12px;">【' + person.ptside + '面' + ptType + '】' + person.picName + '</div><ul style="margin-left:42px;"><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(person.pturl, 80) +
									'"></a><a href="javascript:void(0)" class="bc_gift_name" style="font-size:12px;"> &nbsp; ' + orderResource.picture_code + ': ' + person.ptpicCode + '</a><span>&nbsp;' + person.price + '</span><span class="nums-a">  ' + personNum + '</span><span class="nums-b">' + totalPrice + '</span></li></ul></div>';
								$("#productList").append(dzHtml);
							} else {
								var serviceHtml = '<div class="box-ltx"><p class="list-aa"><span style="font-weight:bold;font-size:12px;" >&nbsp;【' + person.ptside + '面刻字】</span>' + person.ptword + ' </p><p class="list-c">' +
									person.price + '</p><p class="list-d"> ' + personNum + ' </p><p class="list-e">' + totalPrice + '</p></div>';

								$("#productList").append(serviceHtml);
							}

						}

					}

				} else if(sortedList[j].item.salesType == 97) {
					if(shopId == 9) {
						var money = sortedList[j].item.num * sortedList[j].item.price;
					} else {
						var money = (sortedList[j].item.num * sortedList[j].item.price).toFixed(2);
					}
					if(null == sortedList[j].item.gspecStr || sortedList[j].item.gspecStr == "null") {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + cnPcZcActivityModule + "?rid=" + sortedList[j].item.zcid + '" target="_blank"><img src="' + //   //适应https,去掉商品链接,强制不跳转
							changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + cnPcZcActivityModule + "?rid=" + sortedList[j].item.zcid + '" target="_blank">' + sortedList[j].item.name + //' + sortedList[j].item.url + '
							'</a><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
							'</p><p class="list-e">' + money + '</p>';
						$("#productList").append(mainHtml);
						if(sortedList[j].item.isNeedSN == 1) {
							var sn_code = sortedList[j].item.sn;
							if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
								sn_code = '';
							}
							var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b ">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + "_" + sortedList[j].item.materialCode + '" value="' + sn_code + '"></p></div>';
							$("#productList").append(snCode);
						}
					} else {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '" target="_blank"><img src="' + //
							changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '" target="_blank">' + sortedList[j].item.name + '&nbsp;[' + //' + sortedList[j].item.url + '
							sortedList[j].item.gspecStr + ']</a></p><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
							'</p><p class="list-e">' + money + '</p>'
						if(type_t == "dongde") {
							mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '"><img src="' + //
								changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '">' + sortedList[j].item.name + '</a><br><span style="color:#7c7c7c">' + orderResource.portray + '：' + sortedList[j].item.dongPackInfo.productDesc + '</span><br><span style="color:#7c7c7c">' + orderResource.selected_number + '：' + sortedList[j].item.phoneServiceNumber + ',' + sortedList[j].item.cacGoodsinfoes.sfAraeCodeName + '</span></p><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
								'</p><p class="list-e">' + money + '</p>';
						}
						$("#productList").append(mainHtml);
						if(sortedList[j].item.isNeedSN == 1) {
							var sn_code = sortedList[j].item.sn;
							if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
								sn_code = '';
							}
							var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + '" value="' + sn_code + '"></p></div>';
							$("#productList").append(snCode);
						}
					}

				} else {
					var money = (sortedList[j].item.num * sortedList[j].item.price).toFixed(2);
					if(sortedList[j].item.virtualCoinType == 0 || sortedList[j].item.virtualCoinType == 1) {
						if(null == sortedList[j].item.gspecStr || sortedList[j].item.gspecStr == "null") {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '?virtual_currency_area=0 " target="_blank"><img src="' + //   //适应https,去掉商品链接,强制不跳转
								changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '?virtual_currency_area=0 " target="_blank">' + sortedList[j].item.name + //' + sortedList[j].item.url + '
								'</a><p class="list-c">' + sortedList[j].item.priceShow + '</p><p class="list-d">' + sortedList[j].item.num +
								'</p><p class="list-e">' + sortedList[j].item.priceShow + '</p>';
							$("#productList").append(mainHtml);
							if(sortedList[j].item.isNeedSN == 1) {
								var sn_code = sortedList[j].item.sn;
								if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
									sn_code = '';
								}
								var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + "_" + sortedList[j].item.materialCode + '" value="' + sn_code + '"></p></div>';
								$("#productList").append(snCode);
							}
						} else {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '?virtual_currency_area=0 " target="_blank"><img src="' + //
								changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '?virtual_currency_area=0 " target="_blank">' + sortedList[j].item.name + '&nbsp;[' + //' + sortedList[j].item.url + '
								sortedList[j].item.gspecStr + ']</a></p><p class="list-c">' + sortedList[j].item.priceShow + '</p><p class="list-d">' + sortedList[j].item.num +
								'</p><p class="list-e">' + sortedList[j].item.priceShow + '</p>'
							if(type_t == "dongde") {
								mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '"><img src="' + //
									changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '">' + sortedList[j].item.name + '</a><br><span style="color:#7c7c7c">' + orderResource.portray + '：' + sortedList[j].item.dongPackInfo.productDesc + '</span><br><span style="color:#7c7c7c">' + orderResource.selected_number + '：' + sortedList[j].item.phoneServiceNumber + ',' + sortedList[j].item.cacGoodsinfoes.sfAraeCodeName + '</span></p><p class="list-c">' + sortedList[j].item.priceShow + '</p><p class="list-d">' + sortedList[j].item.num +
									'</p><p class="list-e">' + sortedList[j].item.priceShow + '</p>';
							}
							$("#productList").append(mainHtml);
							if(sortedList[j].item.isNeedSN == 1) {
								var sn_code = sortedList[j].item.sn;
								if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
									sn_code = '';
								}
								var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + '" value="' + sn_code + '"></p></div>';
								$("#productList").append(snCode);
							}
						}
					} else {
						if(null == sortedList[j].item.gspecStr || sortedList[j].item.gspecStr == "null") {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '" target="_blank"><img src="' + //   //适应https,去掉商品链接,强制不跳转
								changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '" target="_blank">' + sortedList[j].item.name + //' + sortedList[j].item.url + '
								'</a><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
								'</p><p class="list-e">' + money + '</p>';
							$("#productList").append(mainHtml);
							if(sortedList[j].item.isNeedSN == 1) {
								var sn_code = sortedList[j].item.sn;
								if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
									sn_code = '';
								}
								var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + "_" + sortedList[j].item.materialCode + '" value="' + sn_code + '"></p></div>';
								$("#productList").append(snCode);
							}
						} else {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '" target="_blank"><img src="' + //
								changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '" target="_blank">' + sortedList[j].item.name + '&nbsp;[' + //' + sortedList[j].item.url + '
								sortedList[j].item.gspecStr + ']</a></p><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
								'</p><p class="list-e">' + money + '</p>'
							if(type_t == "dongde") {
								mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.id + '"><p class="list-a"><a href="' + sortedList[j].item.url + '"><img src="' + //
									changeImgSize(sortedList[j].item.imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.url + '">' + sortedList[j].item.name + '</a><br><span style="color:#7c7c7c">' + orderResource.portray + '：' + sortedList[j].item.dongPackInfo.productDesc + '</span><br><span style="color:#7c7c7c">' + orderResource.selected_number + '：' + sortedList[j].item.phoneServiceNumber + ',' + sortedList[j].item.cacGoodsinfoes.sfAraeCodeName + '</span></p><p class="list-c">' + sortedList[j].item.price + '</p><p class="list-d">' + sortedList[j].item.num +
									'</p><p class="list-e">' + money + '</p>';
							}
							$("#productList").append(mainHtml);
							if(sortedList[j].item.isNeedSN == 1) {
								var sn_code = sortedList[j].item.sn;
								if(null == sn_code || sn_code == '' || typeof(sn_code) == 'undefined') {
									sn_code = '';
								}
								var snCode = '<div class="dan"><p class="sn_code_text_container_p list-b">' + orderResource.sn_code + '：<input class="sn_code_text_area" type="text" readonly="readonly" disabled="true" id="sncode_' + sortedList[j].item.id + '" value="' + sn_code + '"></p></div>';
								$("#productList").append(snCode);
							}
						}
					}

					if(sortedList[j].item.gifts.length != 0) {
						$("#" + sortedList[j].item.id).css("border-bottom", "none");
						var giftheader = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.gift + '：</div><ul id="giftUl' + sortedList[j].itemType + sortedList[j].item.id + '">';
						$("#productList").append(giftheader);
						for(var k = 0; k < sortedList[j].item.gifts.length; k++) {
							var giftHtml = '<li class="clearfix"><a href="' + sortedList[j].item.gifts[k].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.gifts[k].imgUrl, 80) + //
								'" ></a><a href="' + sortedList[j].item.gifts[k].url + '" target="_blank" class="bc_gift_name">' + sortedList[j].item.gifts[k].name + '</a><span>&nbsp;</span><span class="nums-a">' + //
								sortedList[j].item.gifts[k].num + '</span><span class="nums-b">&nbsp;</span></li>';
							$("#giftUl" + sortedList[j].itemType + sortedList[j].item.id).append(giftHtml);
						}
						var giftfooter = '</ul></div>';
						$("#productList").append(giftfooter);
					}
					if(sortedList[j].item.services.length != 0) {
						$("#" + sortedList[j].item.id).css("border-bottom", "none");
						for(var k = 0; k < sortedList[j].item.services.length; k++) {
							var money = (sortedList[j].item.services[k].num * sortedList[j].item.services[k].price).toFixed(2);
							var serviceHtml = '<div class="box-ltx"><p class="list-aa">' + orderResource.service + '：' + sortedList[j].item.services[k].name + '</p><p class="list-c">' +
								sortedList[j].item.services[k].price + '</p><p class="list-d">' + sortedList[j].item.services[k].num + '</p><p class="list-e">' + money + '</p></div>';

							$("#productList").append(serviceHtml);
						}
					}
					if(null != sortedList[j].item.thinkCustomInfo) {
						$("#" + sortedList[j].item.id).css("border-bottom", "none");
						var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.customized + '：</div><ul><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(sortedList[j].item.thinkCustomInfo.display, 80) +
							'"></a><a href="javascript:void(0)" class="bc_gift_name">' + sortedList[j].item.thinkCustomInfo.custominfo.customname + '</a><span>&nbsp;</span><span class="nums-a">&nbsp;</span><span class="nums-b">&nbsp;</span></li></ul></div>';
						$("#productList").append(dzHtml);
					}

					//私人订制
					if(null != sortedList[j].item.attributes.personalization && eval('(' + sortedList[j].item.attributes.personalization + ')').length > 0) {
						$("#dzagree").css("display", "block");
						var personNum = sortedList[j].item.num;
						var persons = eval('(' + sortedList[j].item.attributes.personalization + ')');
						for(var k = 0; k < persons.length; k++) {
							$("#" + sortedList[j].item.id).css("border-bottom", "none");
							var person = persons[k];
							var totalPrice = (personNum * parseFloat(person.price)).toFixed(2);

							if(person.ptmode == "1") {
								var ptType = person.pttype == "1" ? "喷印" : "镭雕";
								var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title" style="font-weight:bold;margin-left:12px;">【' + person.ptside + '面' + ptType + '】' + person.picName + '</div><ul style="margin-left:42px;"><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(person.pturl, 80) +
									'"></a><a href="javascript:void(0)" class="bc_gift_name" style="font-size:12px;"> &nbsp; 图片编码: ' + person.ptpicCode + '</a><span>&nbsp;' + person.price + '</span><span class="nums-a">   ' + personNum + '</span><span class="nums-b">' + totalPrice + '</span></li></ul></div>';
								$("#productList").append(dzHtml);
							} else {
								var serviceHtml = '<div class="box-ltx"><p class="list-aa">&nbsp;<span style="font-weight:bold;font-size:12px;" >【' + person.ptside + '面刻字】</span>' + person.ptword + ' </p><p class="list-c">' +
									person.price + '</p><p class="list-d">' + personNum + ' </p><p class="list-e">' + totalPrice + '</p></div>';

								$("#productList").append(serviceHtml);
							}

						}

					}

					/*数据恢复险*/
					var datarecovery = sortedList[j].item.recoveryService;
					if(datarecovery) {
						$("#" + sortedList[j].item.id).css("border-bottom", "none");
						var money = (datarecovery.num * datarecovery.price).toFixed(2);
						var serviceHtml = '<div class="box-ltx db_back" id="dr' + sortedList[j].item.id + '"><p class="list-aa"><span style="color:red;">' + orderResource.data_recovery_insurance + '：</span><i class="i_checkbox" onclick="dataRecoveryClick(this,\'' + sortedList[j].item.id + '\',\'' + sortedList[j].item.itemId + '\')" ></i><a href="' + datarecovery.url + '">' + orderResource.sales_promotion_msg1.format(datarecovery.price) + '</a><b><i class="i_title" style="display: none;"><span class="db_body">' + orderResource.sales_promotion_msg2 + '</span></i><span class="jiao1" style="display: none;"></span><span class="jiao2" style="display: none;"></span> <img class="title_img" onmouseover="title_imgShow(this)" onmouseout="title_imgHide(this)" src="//lenovopic.app.lefile.cn/icon/title.png"></b></p><p class="list-c">' +
							datarecovery.price + '</p><p class="list-d">' + datarecovery.num + '</p><p class="list-e">' + money + '</p></div>';
						$("#productList").append(serviceHtml);
					}
				}
			} else if(sortedList[j].itemType == 3 || sortedList[j].itemType == 2) {
				var titlenameP = orderResource.package;
				if(sortedList[j].itemType == 2) {
					titlenameP = orderResource.options;
				}
				var skuslen = sortedList[j].item.skus.length;
				var clen = 0;
				for(var n = 0; n < skuslen; n++) {
					var innerSku = sortedList[j].item.skus[n];
					var innerXiaoji = (innerSku.num * innerSku.price).toFixed(2);

					if(sortedList[j].item.mainSkuId && sortedList[j].item.mainSkuId != sortedList[j].item.skus[n].id) { //套餐
						if(skuslen == 2) {
							var packageHeader = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + titlenameP + '：</div><ul id="packageUl' + sortedList[j].itemType + sortedList[j].item.mainSkuId + '"></ul></div>';
							$("#productList").append(packageHeader);
							var packageHtml = '<li class="clearfix"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.skus[n].imgUrl, 80) +
								'" ></a><a href="' + sortedList[j].item.skus[n].url + '" class="bc_gift_name" target="_blank">' + sortedList[j].item.skus[n].name + '</a><span>' + //
								sortedList[j].item.skus[n].price + '</span><span class="nums-a">' +
								sortedList[j].item.skus[n].num + '</span><span class="nums-b">' + innerXiaoji + '</span></li>';
							$("#packageUl" + sortedList[j].itemType + sortedList[j].item.mainSkuId).append(packageHtml);
						} else if(skuslen > 2) {
							if(clen == 0) {
								var packageHeader = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + titlenameP + '：</div><ul id="packageUl' + sortedList[j].itemType + sortedList[j].item.mainSkuId + '"></ul></div>';
								$("#productList").append(packageHeader);
								var packageHtml = '<li class="clearfix"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.skus[n].imgUrl, 80) +
									'" ></a><a href="' + sortedList[j].item.skus[n].url + '" class="bc_gift_name" target="_blank">' + sortedList[j].item.skus[n].name + '</a><span>' + //
									sortedList[j].item.skus[n].price + '</span><span class="nums-a">' +
									sortedList[j].item.skus[n].num + '</span><span class="nums-b">' + innerXiaoji + '</span></li>';
								$("#packageUl" + sortedList[j].itemType + sortedList[j].item.mainSkuId).append(packageHtml);
								clen = clen + 1;
							} else {
								var packageHtml = '<li class="clearfix"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.skus[n].imgUrl, 80) +
									'" ></a><a href="' + sortedList[j].item.skus[n].url + '" class="bc_gift_name" target="_blank">' + sortedList[j].item.skus[n].name + '</a><span>' + //
									sortedList[j].item.skus[n].price + '</span><span class="nums-a">' +
									sortedList[j].item.skus[n].num + '</span><span class="nums-b">' + innerXiaoji + '</span></li>';
								$("#packageUl" + sortedList[j].itemType + sortedList[j].item.mainSkuId).append(packageHtml);
							}
						}
					} else {
						var money = (sortedList[j].item.skus[n].num * sortedList[j].item.skus[n].price).toFixed(2);
						if(null == sortedList[j].item.skus[n].gspecStr || sortedList[j].item.skus[n].gspecStr == "null") {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.skus[n].id + '"><p class="list-a"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + //
								changeImgSize(sortedList[j].item.skus[n].imgUrl, 80) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.skus[n].url //
								+
								'" target="_blank">' + sortedList[j].item.skus[n].name +
								'</a><p class="list-c">' + sortedList[j].item.skus[n].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].num +
								'</p><p class="list-e">' + money + '</p>';
							$("#productList").append(mainHtml);
						} else {
							var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.skus[n].id + '"><p class="list-a"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + //
								changeImgSize(sortedList[j].item.skus[n].imgUrl, 80) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.skus[n].url //
								+
								'" target="_blank">' + sortedList[j].item.skus[n].name + '&nbsp;[' +
								sortedList[j].item.skus[n].gspecStr + ']</a><p class="list-c">' + sortedList[j].item.skus[n].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].num +
								'</p><p class="list-e">' + money + '</p>';
							$("#productList").append(mainHtml);
						}

						if(sortedList[j].item.skus[n].gifts.length != 0) {
							$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
							var giftheader = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.gift + '：</div><ul id="giftUl' + sortedList[j].itemType + sortedList[j].item.skus[n].id + '"></ul></div>';
							$("#productList").append(giftheader);
							for(var k = 0; k < sortedList[j].item.skus[n].gifts.length; k++) {
								var giftHtml = '<li class="clearfix"><a href="' + sortedList[j].item.skus[n].gifts[k].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.skus[n].gifts[k].imgUrl, 80) + //
									'" ></a><a href="' + sortedList[j].item.skus[n].gifts[k].url + '" class="bc_gift_name" target="_blank">' + sortedList[j].item.skus[n].gifts[k].name + '</a><span>&nbsp;</span><span class="nums-a">' + //
									sortedList[j].item.skus[n].gifts[k].num + '</span><span class="nums-b">&nbsp;</span></li>';
								$("#giftUl" + sortedList[j].itemType + sortedList[j].item.skus[n].id).append(giftHtml);
							}
						}
						if(sortedList[j].item.skus[n].services.length != 0) {
							$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
							for(var k = 0; k < sortedList[j].item.skus[n].services.length; k++) {
								var money = (sortedList[j].item.skus[n].services[k].num * sortedList[j].item.skus[n].services[k].price).toFixed(2);
								var serviceHtml = '<div class="box-ltx"><p class="list-aa">' + orderResource.service + '：' + sortedList[j].item.skus[n].services[k].name + '</p><p class="list-c">' +
									sortedList[j].item.skus[n].services[k].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].services[k].num + '</p><p class="list-e">' + money + '</p></div>';

								$("#productList").append(serviceHtml);
							}
						}
						if(null != sortedList[j].item.skus[n].thinkCustomInfo) {
							$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
							var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.customized + '：</div><ul><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(sortedList[j].item.skus[n].thinkCustomInfo.display, 80) +
								'"></a><a href="javascript:void(0)" class="bc_gift_name">' + sortedList[j].item.skus[n].thinkCustomInfo.custominfo.customname + '</a><span>&nbsp;</span><span class="nums-a">&nbsp;</span><span class="nums-b">&nbsp;</span></li></ul></div>';
							$("#productList").append(dzHtml);
						}

						//thinkcto
						if(sortedList[j].item.skus[n].attributes.thinkcto != null || sortedList[j].item.skus[n].attributes.fakethinkcto != null) {
							//thinkcto
							var itemArr = [];
							var thinkcto = sortedList[j].item.skus[n].attributes.thinkcto;
							if(!thinkcto) {
								thinkcto = sortedList[j].item.skus[n].attributes.fakethinkcto;
							}
							var personalStr = '';
							var cvItemlength = thinkcto.cvItemList.length;
							for(var m = 0; m < cvItemlength; m++) {
								if(thinkcto.cvItemList[m].isselect == "1") {
									itemArr.push(thinkcto.cvItemList[m]);
								}
							}
							for(var h = 0; h < itemArr.length; h = h + 2) {
								if((h + 1) == itemArr.length) {
									personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%"></td> <td width="35%"></td> </tr>';
								} else {
									personalStr = personalStr + '<tr><td width="15%">' + itemArr[h].char_des + '</td> <td width="35%">' + itemArr[h].charvalue_des + '</td> <td width="15%">' + itemArr[h + 1].char_des + '</td> <td width="35%">' + itemArr[h + 1].charvalue_des + '</td> </tr>';
								}
							}

							$(".config_table").empty().append(personalStr);
							$(".dsix_boxg_cont").eq(1).hide();
							$(".dsix_boxg_cont").eq(2).hide();
							if(itemArr.length > 0) {
								$("#cto_personal").show();
							}
						}

						//私人订制
						if(null != sortedList[j].item.skus[n].attributes.personalization && eval('(' + sortedList[j].item.skus[n].attributes.personalization + ')').length > 0) {
							$("#dzagree").css("display", "block");
							var personNum = sortedList[j].item.skus[n].num;
							var persons = eval('(' + sortedList[j].item.skus[n].attributes.personalization + ')');
							for(var k = 0; k < persons.length; k++) {
								$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
								var person = persons[k];
								var totalPrice = (personNum * parseFloat(person.price)).toFixed(2);

								if(person.ptmode == "1") {
									var ptType = person.pttype == "1" ? "喷印" : "镭雕";
									var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title" style="font-weight:bold;margin-left:14px;">【' + person.ptside + '面' + ptType + '】' + person.picName + '</div><ul style="margin-left:42px;"><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(person.pturl, 80) +
										'"></a><a href="javascript:void(0)" class="bc_gift_name" style="font-size:12px;"> &nbsp; 图片编码: ' + person.ptpicCode + '</a><span>&nbsp;' + person.price + '</span><span class="nums-a">   ' + personNum + '</span><span class="nums-b">' + totalPrice + '</span></li></ul></div>';
									$("#productList").append(dzHtml);
								} else {
									var serviceHtml = '<div class="box-ltx"><p class="list-aa">&nbsp;<span style="font-weight:bold;font-size:12px;" >【' + person.ptside + '面刻字】' + person.ptword + ' </span></p><p class="list-c">' +
										person.price + '</p><p class="list-d">' + personNum + ' </p><p class="list-e">' + totalPrice + '</p></div>';

									$("#productList").append(serviceHtml);
								}
							}
						}
						/*数据恢复险*/
						var datarecovery = sortedList[j].item.skus[n].recoveryService;
						if(datarecovery) {
							$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
							var money = (datarecovery.num * datarecovery.price).toFixed(2);
							var serviceHtml = '<div class="box-ltx db_back" id="dr' + sortedList[j].item.skus[n].id + '"><p class="list-aa"><span style="color:red">' + orderResource.data_recovery_insurance + '：</span><i class="i_checkbox" onclick="dataRecoveryClick(this,\'' + sortedList[j].item.id + '\',\'' + sortedList[j].item.skus[n].itemId + '\')"></i><a href="' + datarecovery.url + '">' + orderResource.sales_promotion_msg1.format(datarecovery.price) + '</a><b><i class="i_title" style="display: none;"><span class="db_body">' + orderResource.sales_promotion_msg2 + '</span></i><span class="jiao1" style="display: none;"></span><span class="jiao2" style="display: none;"></span> <img class="title_img" onmouseover="title_imgShow(this)" onmouseout="title_imgHide(this)" src="//lenovopic.app.lefile.cn/icon/title.png"></b></p><p class="list-c">' +
								datarecovery.price + '</p><p class="list-d">' + datarecovery.num + '</p><p class="list-e">' + money + '</p></div>';
							$("#productList").append(serviceHtml);
						}
						$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
					}
				}
			} else {
				for(var n = 0; n < sortedList[j].item.skus.length; n++) {
					var money = (sortedList[j].item.skus[n].num * sortedList[j].item.skus[n].price).toFixed(2);
					if(null == sortedList[j].item.skus[n].gspecStr || sortedList[j].item.skus[n].gspecStr == "null") {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.skus[n].id + '"><p class="list-a"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + //
							changeImgSize(sortedList[j].item.skus[n].imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.skus[n].url +
							'" target="_blank">' + sortedList[j].item.skus[n].name +
							'</a><p class="list-c">' + sortedList[j].item.skus[n].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].num +
							'</p><p class="list-e">' + money + '</p>';
						$("#productList").append(mainHtml);
					} else {
						var mainHtml = '<div class="divide" style="margin-top: 20px;border-bottom: 1px solid #d9d8d6;"></div><div class="list" id="' + sortedList[j].item.skus[n].id + '"><p class="list-a"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank"><img src="' + //
							changeImgSize(sortedList[j].item.skus[n].imgUrl, 90) + '"></a></p><p class="list-b"><a href="' + sortedList[j].item.skus[n].url + '" target="_blank">' + sortedList[j].item.skus[n].name + '&nbsp;[' + ///
							sortedList[j].item.skus[n].gspecStr + ']</a><p class="list-c">' + sortedList[j].item.skus[n].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].num +
							'</p><p class="list-e">' + money + '</p>';
						$("#productList").append(mainHtml);
					}

					if(sortedList[j].item.skus[n].gifts.length != 0) {
						$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
						var giftheader = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.gift + '：</div><ul id="giftUl' + sortedList[j].itemType + sortedList[j].item.skus[n].id + '"></ul></div>';
						$("#productList").append(giftheader);
						for(var k = 0; k < sortedList[j].item.skus[n].gifts.length; k++) {
							var giftHtml = '<li class="clearfix"><a href="' + sortedList[j].item.skus[n].gifts[k].url + '" target="_blank"><img src="' + changeImgSize(sortedList[j].item.skus[n].gifts[k].imgUrl, 80) + //
								'" ></a><a href="' + sortedList[j].item.skus[n].gifts[k].url + '" class="bc_gift_name" target="_blank">' + sortedList[j].item.skus[n].gifts[k].name + '</a><span>&nbsp;</span><span class="nums-a">' + //
								sortedList[j].item.skus[n].gifts[k].num + '</span><span class="nums-b">&nbsp;</span></li>';
							$("#giftUl" + sortedList[j].itemType + sortedList[j].item.skus[n].id).append(giftHtml);
						}
					}
					if(sortedList[j].item.skus[n].services.length != 0) {
						$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
						for(var k = 0; k < sortedList[j].item.skus[n].services.length; k++) {
							var money = (sortedList[j].item.skus[n].services[k].num * sortedList[j].item.skus[n].services[k].price).toFixed(2);
							var serviceHtml = '<div class="box-ltx"><p class="list-aa">' + orderResource.service + '：' + sortedList[j].item.skus[n].services[k].name + '</p><p class="list-c">' +
								sortedList[j].item.skus[n].services[k].price + '</p><p class="list-d">' + sortedList[j].item.skus[n].services[k].num + '</p><p class="list-e">' + money + '</p></div>';

							$("#productList").append(serviceHtml);
						}
					}
					if(null != sortedList[j].item.skus[n].thinkCustomInfo) {
						$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
						var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title">' + orderResource.customized + '：</div><ul><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(sortedList[j].item.skus[n].thinkCustomInfo.display, 80) +
							'"></a><a href="javascript:void(0)" class="bc_gift_name">' + sortedList[j].item.skus[n].thinkCustomInfo.custominfo.customname + '</a><span>&nbsp;</span><span class="nums-a">&nbsp;</span><span class="nums-b">&nbsp;</span></li></ul></div>';
						$("#productList").append(dzHtml);
					}
					//私人订制
					if(null != sortedList[j].item.skus[n].attributes.personalization && eval('(' + sortedList[j].item.skus[n].attributes.personalization + ')').length > 0) {
						$("#dzagree").css("display", "block");
						var personNum = sortedList[j].item.skus[n].num;
						var persons = eval('(' + sortedList[j].item.skus[n].attributes.personalization + ')');
						for(var k = 0; k < persons.length; k++) {
							$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
							var person = persons[k];
							var totalPrice = (personNum * parseFloat(person.price)).toFixed(2);

							if(person.ptmode == "1") {
								var ptType = person.pttype == "1" ? "喷印" : "镭雕";
								var dzHtml = '<div class="bc_gift_bot clearfix"><div class="bc_bot_title" style="font-weight:bold;margin-left:14px;">【' + person.ptside + '面' + ptType + '】' + person.picName + '</div><ul style="margin-left:42px;"><li class="clearfix"><a href="javascript:void(0)"><img src="' + changeImgSize(person.pturl, 80) +
									'"></a><a href="javascript:void(0)" class="bc_gift_name" style="font-size:12px;"> &nbsp; 图片编码: ' + person.ptpicCode + '</a><span>&nbsp;' + person.price + '</span><span class="nums-a">   ' + personNum + '</span><span class="nums-b">' + totalPrice + '</span></li></ul></div>';
								$("#productList").append(dzHtml);
							} else {
								var serviceHtml = '<div class="box-ltx"><p class="list-aa">&nbsp;<span style="font-weight:bold;font-size:12px;" >【' + person.ptside + '面刻字】' + person.ptword + ' </span></p><p class="list-c">' +
									person.price + '</p><p class="list-d">' + personNum + ' </p><p class="list-e">' + totalPrice + '</p></div>';

								$("#productList").append(serviceHtml);
							}
						}
					}
					/*数据恢复险*/
					var datarecovery = sortedList[j].item.skus[n].recoveryService;
					if(datarecovery) {
						$("#" + sortedList[j].item.skus[n].id).css("border-bottom", "none");
						var money = (datarecovery.num * datarecovery.price).toFixed(2);
						var serviceHtml = '<div class="box-ltx db_back" id="dr' + sortedList[j].item.skus[n].id + '"><p class="list-aa"><span style="color:red">' + orderResource.data_recovery_insurance + '：</span><i class="i_checkbox" onclick="dataRecoveryClick(this,\'' + sortedList[j].item.id + '\',\'' + sortedList[j].item.skus[n].itemId + '\')"></i><a href="' + productDetail + '/' + datarecovery.id + '&#46;html">' + orderResource.sales_promotion_msg1.format(datarecovery.price) + '</a><b><i class="i_title" style="display: none;"><span class="db_body">' + orderResource.sales_promotion_msg2 + '</span></i><span class="jiao1" style="display: none;"></span><span class="jiao2" style="display: none;"></span> <img class="title_img" onmouseover="title_imgShow(this)" onmouseout="title_imgHide(this)" src="//lenovopic.app.lefile.cn/icon/title.png"></b></p><p class="list-c">' +
							datarecovery.price + '</p><p class="list-d">' + datarecovery.num + '</p><p class="list-e">' + money + '</p></div>';
						$("#productList").append(serviceHtml);
					}
				}
			}
		}
	}
	if(order) {
		$(".db_back").each(function(i, n) {
			$(n).removeClass("db_checked")

		});
		var drArr = order.split(",");
		for(var i = 0; i < drArr.length; i++) {
			$("#dr" + drArr[i]).addClass("db_checked")
		}
	}
}

function changeImgSize(img, size) {
	if(img && img.indexOf("pic.17.lenovo.com.cn") < 0) {
		return img.replace(img.split('.')[img.split('.').length - 1], "w" + size + "." + img.split('.')[img.split('.').length - 1]);
	} else {
		return img;
	}
}
//数据恢复险
function datarecovery(id, itemid, check) {
	var ajaxdata = {
		itemId: itemid.toString(),
		check: check,
		direct: buyType
	};
	$.ajax({
		type: "post",
		url: buy_order.URL.datarecovery(),
		async: false,
		data: ajaxdata,
		dataType: "json",
		success: function(data) {
			if(data != null) {
				if(data.rc != null && data.rc == "0") {
					updatedatarecovery();
				} else {
					$("#dr" + id).parents(".db_back").removeClass("db_checked");
					if(null != data.msg && '' != data.msg) {
						showMessage(3000, data.msg);
					} else {
						showMessage(3000, orderResource.system_busy_try_again_later);
					}
				}
			}
		}
	});
}
//渲染优惠券列表
function showCouponList(data, order, discountsViewInfo) {
	if(discountsViewInfo != "" && discountsViewInfo.showCoupon == 0) {
		$("#couponlist").hide();
	}
	if(data != null && data != "") {
		showCoupon(data, order);
	}
}
//渲染优惠码
function showCouponCode(order, discountsViewInfo) {
	if(discountsViewInfo != "" && discountsViewInfo.showCouponCode == 0) {
		$("#couponcodeDiv").hide();
	}
	if(order != null && order != "") {
		$("#couponcode").val(order);
		$("#couponcheck").attr("checked", true);
		$("#couponcode").attr("readonly", true);
	}
}
//渲染增票
function showInvoice(data, order) {
	if(data == "") {
		$(".box-c").css("display", "none");
	}
	if(data || shopId == 8) {
		checkshow(data, order);
	}
}
//渲染价格
function showPrice(data, order) {
	var flag = false;
	if(order.checkoutType == "presell") {
		flag = true;
	}
	if(data == "") {
		$("#discountinfo").css("display", "none");
	} else {
		if(order.checkoutType == "consumer_score") {
			$("#totalPriceJF").text(orderResource.currency_symbol + data.totalPrice + "+" + data.virtualCoin + "积分");
			$("#point").text(data.virtualCoin);
			$("#freight").text(orderResource.currency_symbol + data.freight);
			$("#paymoney").text(orderResource.currency_symbol + data.totalPay);
			$("#p_totalPriceJF").css("display", "block");
			$("#p_point").css("display", "block");
			$("#p_freight").css("display", "block");
			$("#p_paymoney").css("display", "block");
			$("#p_payDeposit").css("display", "none");
			$("#p_restPrice").css("display", "none");
			$("#tiptext").css("display", "none");
			$("#p_ldou").css("display", "none");
			$("#p_totalPriceLD").css("display", "none");
			$("#p_totalPrice").css("display", "none");
		} else if(order.checkoutType == "lebean") {
			$("#totalPriceLD").text(orderResource.currency_symbol + data.totalPrice + "+" + data.virtualCoin + "乐豆");
			$("#ldou").text(data.virtualCoin);
			$("#freight").text(orderResource.currency_symbol + data.freight);
			$("#paymoney").text(orderResource.currency_symbol + data.totalPay);
			$("#p_totalPriceLD").css("display", "block");
			$("#p_ldou").css("display", "block");
			$("#p_freight").css("display", "block");
			$("#p_paymoney").css("display", "block");
			$("#p_point").css("display", "none");
			$("#p_payDeposit").css("display", "none");
			$("#p_restPrice").css("display", "none");
			$("#tiptext").css("display", "none");
			$("#p_totalPriceJF").css("display", "none");
			$("#p_totalPrice").css("display", "none");

		} else {
			$("#zj").text(data.allCouponDiscount);
			$("#totalPrice").text(orderResource.currency_symbol + data.totalPrice);
			if(data.totalDiscount != 0) {
				$("#totaldiscount").text("-" + orderResource.currency_symbol + data.totalDiscount);
			} else {
				$("#totaldiscount").text(orderResource.currency_symbol + data.totalDiscount);
			}
			if(data.allCouponDiscountWithCode != 0) {
				$("#youhuij").text("-" + orderResource.currency_symbol + data.allCouponDiscountWithCode);
			} else {
				$("#youhuij").text(orderResource.currency_symbol + data.allCouponDiscountWithCode);
			}
			$("#freight").text(orderResource.currency_symbol + data.freight);
			$("#paymoney").text(orderResource.currency_symbol + data.totalPay);
			if(flag) {
				$("#payDeposit").text(orderResource.currency_symbol + data.depositPrice);
				$("#finalPrice").text(orderResource.currency_symbol + data.restPrice);
				$("#p_point").css("display", "none");
				$("#p_ldou").css("display", "none");
				$("#p_freight").css("display", "none");
				$("#p_paymoney").css("display", "none");
				$("#p_totalPriceJF").css("display", "none");
				$("#p_totalPriceLD").css("display", "none");
				$("#p_payDeposit").css("display", "block");
				$("#p_restPrice").css("display", "block");
				$("#tiptext").css("display", "block");
			} else {
				$("#p_freight").css("display", "block");
				$("#p_paymoney").css("display", "block");
				$("#p_totalPriceJF").css("display", "none");
				$("#p_totalPriceLD").css("display", "none");
				$("#p_payDeposit").css("display", "none");
				$("#p_ldou").css("display", "none");
				$("#p_point").css("display", "none");
				$("#p_restPrice").css("display", "none");
				$("#tiptext").css("display", "none");
			}

			$("#discountinfo").css("display", "block");

		}
	}
}

function showScores(data) {
	$("#discountinfo").empty();
	var scoreStr = '<p><span>' + orderResource.current_point + '：<em style="color: #e2231a;font-weight: bold;font-style: normal;" >' + data.totalScore + '</em></span></p>' +
		'<p><span>' + orderResource.exchange_needed_point + '：<em style="color: #e2231a;font-weight: bold;font-style: normal;" >' + data.totalPay + '</em></span></p>' +
		'<p id="submitbutton" style="margin-bottom: 15px;"><button onclick="submitOrder()" event-name="' + orderResource.pc_client_submit_order + '"  style="font-size: 18px;cursor: pointer;margin-top: 2px;">' + orderResource.submit_order + '</button></p>';
	$("#discountinfo").append(scoreStr);
}
//设置众筹订单数据
function showzc(data, temp) {
	var zcvalue = data[0];
	if(zcvalue == 97 || temp == "consumer_score" || temp == "lebean") {
		$("#discount").css("display", "none");
		$("#pricesubmit").css("display", "none");
	} else {
		$("#discount").css("display", "block");
		$("#pricesubmit").css("display", "block");
	}
}
//渲染内购额度组件
function showInnerBuyWidget(data, order) {
	if(data == "") {
		$("#innerlimitmoney").css("display", "none");
	} else {
		if(data.isCanUseInner == 0) {
			$("#innerlimitmoney").css("display", "none");
		}
		if(data.isCanUseInner == 1) {
			$("#userCanuseInnerBuy").text(data.totalInner);
			$("#innerbuySum").text(data.maxUseInner);
			$("#innerlimitmoney").css("display", "block");
		}
	}
	if(order != null && order != "") {
		$("#innerLimitMoney").val(order);
		$("#innerLimitcheck").attr("checked", true);
		$("#innerLimitMoney").attr("readonly", true);
	}
}

//渲染内购额度组件
function showCashCouponWidget(data, order) {
	if(data == "") {
		$("#cashCouponmoney").css("display", "none");
	} else {
		if(data.isCanUseCashCoupon == 0) {
			$("#cashCouponmoney").css("display", "none");
		}
		if(data.isCanUseCashCoupon == 1) {
			$("#userCanuseCashCoupon").text(data.totalCashCoupon);
			$("#cashbuySum").text(data.usableCashCoupon);
			$("#cashCouponmoney").css("display", "block");
		}
	}
	if(order != null && order != "") {
		$("#cashMoney").val(order);
		$("#cashCouponcheck").attr("checked", true);
		$("#cashMoney").attr("readonly", true);
	}
}
//渲染乐豆组件
function showHappyBeanWidget(data, order, discountsViewInfo) {
	if(data == "" || (discountsViewInfo != "" && discountsViewInfo.showLeBean == 0)) {
		$("#happyBeanNum").css("display", "none");
	} else {
		if(data.isCanUseLeBean == 0) {
			$("#happyBeanNum").css("display", "none");
		}
		if(data.isCanUseLeBean == 1) {
			var tBean = data.totalLeBean; //用户总乐豆
			var uBean = data.usableLeBean; //可用乐豆

			$("#LeDouTotalCount").text(tBean);
			$("#availableHappyBeanNum").text(uBean);
			$("#happyBeanNum").css("display", "block");

			//使用的乐豆数只能是100的整数倍，，此处默认填写能使用的乐豆的最大数（且是100的整数倍）
			var dBean = tBean < uBean ? parseInt(tBean / 100) * 100 : parseInt(uBean / 100) * 100;
			if(dBean != 0) {
				$("#useHappyBeanNum").val(dBean);
			}
		}
	}
	if(order != null && order != "") {
		if(order == 0) {
			$("#useHappyBeanNum").val("");
			$("#happyBeancheck").attr("checked", false);
			$("#useHappyBeanNum").removeAttr("readonly");
		} else {
			$("#useHappyBeanNum").val(order);
			$("#happyBeancheck").attr("checked", true);
			$("#useHappyBeanNum").attr("readonly", true);
		}

	}
}
//展示sn
function showsn(data, order) {
	if(data) {
		$("#sncode").css("display", "block");
	} else {
		$("#sncode").css("display", "none");
	}
	if(order != null && order != "") {
		$("#sercicecode").val(order);
		$("#sncheck").attr("checked", true);
		$("#sercicecode").attr("readonly", true);
	}
}
/////////////////////////////////////////////////
//获取数据（渲染、展示）--结束
////////////////////////////////////////////////

/////////////////////////////////////////////////
//更新缓存--开始
////////////////////////////////////////////////
function updateMoreCheckOutCache(invoice_order, isSendContract_order) {
	var invoice_u = "";
	if(invoice_order) {
		invoice_u = invoice_order;
	} else {
		invoice_u = getInvoice11();
	}
	var deleverType = $("#deleverType").val();
	if(null == deleverType || '' == deleverType || 'undefined' == deleverType || deleverType == undefined) {
		deleverType = -1;
	}
	var paywaydata = getPayWay();
	var ajaxdata = {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItems: [UpdateBackFillItem.DELIVER, UpdateBackFillItem.INVOICE, UpdateBackFillItem.PAYTYPE, UpdateBackFillItem.DELEVER_GOODS_TYPE],
		consigneeId: getChoseId(type_t == "dongde" ? AddressTypeEnums.DONGDE : AddressTypeEnums.SH),
		invoice: invoice_u,
		paytype: paywaydata,
		deliverGoodsType: deleverType,
		ss: new Date().getTime()
	}
	if(shopId == 8 && !isSendContract_order) {
		ajaxdata.cacheItems.push(UpdateBackFillItem.CONTRACTADDRESS);
		ajaxdata.cacheItems.push(UpdateBackFillItem.CONTRACTISCONSIGNEE);
		ajaxdata.cacheItems.push(UpdateBackFillItem.ISSENDCONTRACT);
		ajaxdata.contractIsConsigneeId = "0";
		ajaxdata.contractAddressId = "";
		ajaxdata.isSendContract = "0";
	}
	updateCheckOutCacheList(ajaxdata, null);
}

function updateCheckOutCacheList(ajaxdata, addresstype) {
	$.post(buy_order.URL.updateMoreCheckOutCache(), ajaxdata, function(data) {
		if(data != null) {
			if(data.rc == 0) { //更新缓存成功
				if(addresstype && addresstype == AddressTypeEnums.HT) {
					contractAddressOperate(ajaxdata.isSendContract, ajaxdata.contractIsConsigneeId, ajaxdata.contractAddressId);
				} else if(addresstype && addresstype == AddressTypeEnums.SP) {
					invoiceAddressOperate(ajaxdata.invoiceIsConsigneeId, ajaxdata.invoiceAddressId);
				}
			} else {
				if(null != data.msg && '' != data.msg && 'undefined' != data.msg) {
					showMessage(3000, data.msg);
				} else {
					showMessage(3000, orderResource.system_busy_try_again_later);
				}
			}
		}
	}, 'json');
}
/*address param*/
function makeContentParam(content, param) {
	var isCheckout = false;
	if(content != "") {
		/*
		 开头为D
		 删除地址----content传递"D"+consigneeId
		 开头为A
		 只更新地址没有对默认地址的状态进行修改---content只传递"A"
		 更新地址又同时修改默认地址的状态            ---content传递"A"+consigneeId
		 其他情况不做任何处理--（更新地址缓存）不需要checkout
		 */
		var content_temp = content;
		var consigneeStatus = content.substring(0, 1);
		content = content.substring(1);
		if(consigneeStatus == "D") { //删除
			if(param == content) {
				param = "";
			}
			content = param;
			isCheckout = true;
		} else if(consigneeStatus == "A") { //新增或是更新或是只是刷新
			if(content == "") {
				content = param;
			}
			isCheckout = true;
		} else {
			content = content_temp;
			param = content_temp;
		}
	} else {
		param = "";
	}
	dataContent = {};
	dataContent.isCheckout = isCheckout;
	dataContent.content = content;
	dataContent.shareParam = param;
	return dataContent;
}

function updateCheckOutCache(updateItem, content) {
	var isCheckout = false;
	var deliverData;
	if(updateItem == UpdateBackFillItem.DELIVER) {
		deliverData = makeContentParam(content, shareConsigneeId);
		shareConsigneeId = deliverData.shareParam;
		isCheckout = deliverData.isCheckout;
		content = deliverData.content;
	} else if(updateItem == UpdateBackFillItem.INVOICEADDRESS) {
		deliverData = makeContentParam(content, shareInvoiceAddressId);
		shareInvoiceAddressId = deliverData.shareParam;
		isCheckout = deliverData.isCheckout;
		content = deliverData.content;
	} else if(updateItem == UpdateBackFillItem.CONTRACTADDRESS) {
		deliverData = makeContentParam(content, shareContractAddressId);
		shareContractAddressId = deliverData.shareParam;
		isCheckout = deliverData.isCheckout;
		content = deliverData.content;
	}
	$.post(buy_order.URL.updateCheckOutCache(), {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItem: updateItem,
		content: content,
		ss: new Date().getTime()
	}, function(data) {
		if(data != null) {
			if(data.rc == 0) { //更新缓存成功
				if(updateItem == UpdateBackFillItem.ISSENDCONTRACT || updateItem == UpdateBackFillItem.CONTRACTISCONSIGNEE || updateItem == UpdateBackFillItem.INVOICEISCONSIGNEE || updateItem == UpdateBackFillItem.INVOICE || updateItem == UpdateBackFillItem.PAYTYPE) {
					//地址、发票、支付方式 ,收票地址是否同收货地址,合同地址是否同收货地址,是否寄送合同不需要checkout
				} else {
					if(updateItem == UpdateBackFillItem.DELIVER || updateItem == UpdateBackFillItem.INVOICEADDRESS || updateItem == UpdateBackFillItem.CONTRACTADDRESS) {
						if(isCheckout) {
							getcheckOutData(global_ajaxdomain, terminal);
						}
					} else {
						getcheckOutDataNew(global_ajaxdomain, terminal, updateItem); //更新缓存成功--重新渲染
					}
				}
			} else {
				cleanInput(updateItem, 1);
				if(null != data.msg && '' != data.msg && 'undefined' != data.msg) {
					showMessage(3000, data.msg);
				} else {
					showMessage(3000, orderResource.system_busy_try_again_later);
				}
			}
		}
	}, 'json');
}

function updateCheckOutCacheNew(updateItem, content) {
	$.post(buy_order.URL.updateCheckOutCache(), {
		lid: lid,
		shopId: shopId,
		terminal: terminal,
		cacheItem: updateItem,
		content: content,
		ss: new Date().getTime()
	}, function(data) {
		if(data != null) {
			if(data.rc == 0) { //更新缓存成功
			} else {
				cleanInput(updateItem, 1); //更新缓存失败，不重新更新缓存
				if(null != data.msg && '' != data.msg && 'undefined' != data.msg) {
					showMessage(3000, data.msg);
				} else {
					showMessage(3000, orderResource.system_busy_try_again_later);
				}
			}
		}
	}, 'json');
}
//清空输入框,并清空缓存
function cleanInput(updateItem, type) {
	switch(updateItem) {
		case 7: //优惠码
			$("#couponcode").val("");
			$("#couponcheck").attr("checked", false);
			$("#couponcode").focus();
			$("#couponcode").removeAttr("readonly");
			break;
		case 8: //内购
			$('#innerLimitMoney').val("");
			$("#innerLimitcheck").attr("checked", false);
			$("#innerLimitMoney").focus();
			$("#innerLimitMoney").removeAttr("readonly");
			break;
		case 10: //乐豆
			$('#useHappyBeanNum').val("");
			$("#happyBeancheck").attr("checked", false);
			$("#useHappyBeanNum").focus();
			$("#useHappyBeanNum").removeAttr("readonly");
			break;
		case 11: //SN
			$('#sercicecode').val("");
			$("#sncheck").attr("checked", false);
			$("#sercicecode").focus();
			$("#sercicecode").removeAttr("readonly");
			break;
		case 25: //代金券
			$('#cashMoney').val("");
			$("#cashCouponcheck").attr("checked", false);
			$("#cashMoney").focus();
			$("#cashMoney").removeAttr("readonly");
			break;
		default:
	}
	if(type == 2) {
		updateCheckOutCacheNew(updateItem, "");
	}
}
//使用成功弹框提醒
function alertSuccess(updateItem) {
	switch(updateItem) {
		case 7: //优惠码
			if($("#couponcheck").is(":checked")) {
				showMessage(3000, orderResource.use_coupon_code_success);
			}
			break;
		case 8: //内购
			if($("#innerLimitcheck").is(":checked")) {
				showMessage(3000, orderResource.use_inner_money_success);
			}
			break;
		case 10: //乐豆
			if($("#happyBeancheck").is(":checked")) {
				showMessage(3000, orderResource.use_le_dou_success);
			}
			break;
		case 25: //代金券
			if($("#cashCouponcheck").is(":checked")) {
				showMessage(3000, "使用代金券成功！");
			}
			break;
		case 11: //SN
			if($("#sncheck").is(":checked")) {
				showMessage(3000, orderResource.use_sn_code_success);
			}
			break;
		default:
	}
}
//
function updateAddressCache(id, addresstype) {
	if(addresstype == AddressTypeEnums.SP) {
		updateCheckOutCache(UpdateBackFillItem.INVOICEADDRESS, id);
	} else if(addresstype == AddressTypeEnums.SH || addresstype == AddressTypeEnums.DONGDE) {
		updateCheckOutCache(UpdateBackFillItem.DELIVER, id);
	} else if(addresstype == AddressTypeEnums.HT) {
		updateCheckOutCache(UpdateBackFillItem.CONTRACTADDRESS, id);
	}
}
//收货人地址
function updateConsignee(addresstype) {
	var addressId = getChoseId(addresstype);
	if(addresstype == AddressTypeEnums.DONGDE || addresstype == AddressTypeEnums.SH) {
		updateCheckOutCache(UpdateBackFillItem.DELIVER, addressId);
	} else if(addresstype == AddressTypeEnums.SP) {
		updateCheckOutCache(UpdateBackFillItem.INVOICEADDRESS, addressId);
	} else if(addresstype == AddressTypeEnums.HT) {
		updateCheckOutCache(UpdateBackFillItem.CONTRACTADDRESS, addressId);
	}
}
//支付方式
function updatePayType() {
	var paytype = "0";
	paytype = getPayWay();
	if(paytype == undefined) {
		paytype = "0";
	}
	updateCheckOutCache(UpdateBackFillItem.PAYTYPE, paytype);
}

//优惠券
function updateCouponids() {
	var couponids = getCheckedCouponsByArr();
	usevirtualcurrency(UpdateBackFillItem.COUPONIDS, couponids);
}
//获取优惠券ids
function getCheckedCoupons() {
	var couponids = "";
	var ids = [];
	$("#tab_01 .bgses").each(function(i, n) {
		if($(n).hasClass("pinks")) {
			var id = $(n).attr("id");
			ids.push(id);
		}
	});
	couponids = ids.join(",");
	return couponids;
}

function getCheckedCouponsByArr() {
	var couponids = "";
	var ids = couponidArr;
	couponids = ids.join(",");
	return couponids;
}
//优惠码
function updateCouponCode() {
	var couponcode = $('#couponcode').val();
	usevirtualcurrency(UpdateBackFillItem.COUPONCODE, couponcode);
}
//乐豆
function updateHappyBeanNum() {
	var happybean = $('#useHappyBeanNum').val();
	usevirtualcurrency(UpdateBackFillItem.HAPPYBEAN, $.trim(happybean));
}
//内购限额
function updateInnerLimitMoney() {
	var innerBuyMoney = $('#innerLimitMoney').val();
	usevirtualcurrency(UpdateBackFillItem.INNERBUYMONEY, innerBuyMoney);
}

//代金券
function updateCashCouponMoney() {
	var cashMoney = $('#cashMoney').val();
	usevirtualcurrency(UpdateBackFillItem.CASHMONEY, cashMoney);
}
//sn
function updateSNCode() {
	var sercicecode = $("#sercicecode").val();
	updateCheckOutCache(UpdateBackFillItem.SN, sercicecode);
}

//数据恢复险
function updatedatarecovery() {
	var insurances = getInsurances();
	usevirtualcurrency(UpdateBackFillItem.DATARECOVERY, insurances);
}

function getInsurances() {
	var insuranceArr = new Array();
	$(".db_back").each(function(i, n) {
		if($(n).hasClass("db_checked")) {
			var id = $(n).attr("id");
			insuranceArr.push(id.substring(2));
		}
	});
	var insuranceStr = insuranceArr.join(",");
	return insuranceStr;
}
//预售电话
function updatePresellTel(presellTel) {
	usevirtualcurrency(UpdateBackFillItem.PRESELLTEL, presellTel);
}
/////////////////////////////////////////////////
//更新缓存--结束
////////////////////////////////////////////////

function checkdata(val, cur) {
	if(getCheckEmpty(val)) {
		return "";
	} else {
		if(getCheckEmpty(cur)) {
			return "";
		} else {
			return cur;
		}
	}
}
/*Returns true if empty*/
function getCheckEmpty(val) {
	if(val == null || val == "" || val == undefined || val == "undefined" || val == "null") {
		return true;
	} else {
		return false;
	}
}

function renderPage(temp, order, updateItem) {
	/*invoiceAddress public*/
	shareInvoiceAddressId = checkdata(order, order.invoiceAddressId);

	type_t = temp.checkoutType;
	buyType = order.buyType;
	if(updateItem != null) {
		alertSuccess(updateItem);
	}
	if(shopId == 14) {
		$(".box-c").css("height", "130px");
	}
	// showConsign(checkdata(temp, temp.consignee), checkdata(order, order.consigneeId));
	shareConsigneeId = checkdata(order, order.consigneeId);
	if(type_t == "dongdenonumber") {
		showDongdeDirectPage(temp, order);
	} else if(type_t == "dongde") {
		showDongdePage(temp, order);
	} else if(shopId == 9 || shopId == 15) { //17积分 和 惠商积分
		/*checkdata(temp, temp.scoreApiVo) && temp.scoreApiVo.isCanUseScore == 1*/
		showScorePage(temp, order);
	} else {
		showShopPage(temp, order);
	}
	//使用优惠券成功的提示
	//if (temp.successMsg != undefined && temp.successMsg != null && temp.successMsg != "" && temp.successMsg != "success") {
	//    showMessage(2000, temp.successMsg);
	//}

}

function showScorePage(temp, order) {
	/*orderBase.removeContract();
	 orderBase.removeInvoice();
	 orderBase.removePayType();
	 orderDiscount.removeDiscount();
	 orderAgree.removeAgree();
	 orderNotes.removeNotes();*/
	orderBase.removePayType(); //去样式
	showConsignList(checkdata(temp, temp.consignees), checkdata(order, order.consigneeId), AddressTypeEnums.SH);
	showCartList(checkdata(temp, temp.checkOutCart), checkdata(order, order.datarecovery), checkdata(order, order.buyType), checkdata(order, order), temp);
	showScores(checkdata(temp, temp.statistics));
	updateConsignee(AddressTypeEnums.SH);
}

function showDongdeDirectPage(temp, order) {
	orderBase.removeContract();
	orderBase.removeInvoice();
	showShopPage(temp, order);
}

function showDongdePage(temp, order) {
	showConsignList(checkdata(temp, temp.consignees), checkdata(order, order.consigneeId), AddressTypeEnums.DONGDE);
	orderBase.removeContract();
	orderBase.removeInvoice();
	//orderDiscount.removeDiscount();
	orderNotes.removeNotes();
	agree_conditon();
	showPayType(checkdata(temp, temp.usablePayTypes), checkdata(order, order.paytype), temp, order);
	showCartList(checkdata(temp, temp.checkOutCart), checkdata(order, order.datarecovery), checkdata(order, order.buyType), checkdata(order, order), temp);
	showPrice(checkdata(temp, temp.statistics), temp);

	showHappyBeanWidget(checkdata(temp, temp.leBeanApiVo), checkdata(order, order.happyBeanNum), checkdata(temp, temp.discountsViewInfo));
	showCouponList(checkdata(temp, temp.couponList), checkdata(order, order.couponids), checkdata(temp, temp.discountsViewInfo));
	showCouponCode(checkdata(order, order.couponcode), checkdata(temp, temp.discountsViewInfo));
	updateMoreCheckOutCache(checkdata(order, order.invoice), checkdata(order, order.isSendContract));
	if(shopId == 8) {
		invoiceAddressOperate(checkdata(order, order.invoiceIsConsigneeId), checkdata(order, order.invoiceAddressId))
		contractAddressOperate(checkdata(order, order.isSendContract), checkdata(order, order.contractIsConsigneeId), checkdata(order, order.contractAddressId));
	}
}

function showShopPage(temp, order) {
	showConsignList(checkdata(temp, temp.consignees), checkdata(order, order.consigneeId), AddressTypeEnums.SH);

	showInnerBuyWidget(checkdata(temp, temp.innerApiVo), checkdata(order, order.innerBuyMoney));
	showCashCouponWidget(checkdata(temp, temp.cashCouponApiVo), checkdata(order, order.cashCouponMoney));
	showzc(checkdata(temp, temp.saleTypeSet), checkdata(temp, temp.checkoutType));
	showsn(checkdata(temp, temp.needSN), checkdata(order, order.servicesn));
	if(shopId == 14) { //惠商隐藏优惠码乐豆
		orderDiscount.removeCouponcode();
		orderDiscount.removeHappyBeanNum();
		$("#managercode").parents('.dan').css("display", "none"); //惠商隐藏客户经理
	} else {
		showCouponCode(checkdata(order, order.couponcode), checkdata(temp, temp.discountsViewInfo));
		showHappyBeanWidget(checkdata(temp, temp.leBeanApiVo), checkdata(order, order.happyBeanNum), checkdata(temp, temp.discountsViewInfo));
	}
	showCouponList(checkdata(temp, temp.couponList), checkdata(order, order.couponids), checkdata(temp, temp.discountsViewInfo));

	showPayType(checkdata(temp, temp.usablePayTypes), checkdata(order, order.paytype), temp, order);
	showDeliverGoodsType(temp, order);
	showCartList(checkdata(temp, temp.checkOutCart), checkdata(order, order.datarecovery), checkdata(order, order.buyType), checkdata(order, order), temp);

	showInvoice(checkdata(temp, temp.usableInvoices), checkdata(order, order.invoice));
	showPrice(checkdata(temp, temp.statistics), temp);
	updateMoreCheckOutCache(checkdata(order, order.invoice), checkdata(order, order.isSendContract));
	if(shopId == 8) {
		invoiceAddressOperate(checkdata(order, order.invoiceIsConsigneeId), checkdata(order, order.invoiceAddressId))
		contractAddressOperate(checkdata(order, order.isSendContract), checkdata(order, order.contractIsConsigneeId), checkdata(order, order.contractAddressId));
	}
	//changeMoney();
}

function showDeliverGoodsType(obj, orderObj) {
	if(obj != null && null != obj.deliverGoodsType) {
		var html = '<p class="address—p line50" >送货方式：<div ><input type="hidden" id="deleverType">';
		var type = "";
		$.each(obj.deliverGoodsType, function(i, o) {
			var checked = "";
			if(o.isdefault == 1) {
				checked = "pink";
				type = o.type;
			}

			//html += "&nbsp;&nbsp;<input   type='radio' name='deliverGoodsType' "+checked+" value='"+ o.type+"'  />&nbsp;&nbsp;" + o.name;
			html += ' <div style="cursor:pointer;" class="box-ax bgse ' + checked + '"  onclick="chooseDelever(' + o.type + ')" id="delever_' + o.type + '" value="' + o.type + '" >' +
				' <p><span>' + o.name + '</span></p>' +
				' <img src="' + pcImgHomeModule + '/base/pic-07.jpg' + '" id="icon">' +
				' </div>';
		});
		html += "</div><p>";
		$(".box-e").html(html);
		$("#deleverType").val(type);
		if(orderObj != null && orderObj != "" && null != orderObj.deliverGoodsType && orderObj.deliverGoodsType != '') {
			$("#delever_" + orderObj.deliverGoodsType).addClass("pink").siblings().removeClass("pink");
			$("#deleverType").val(orderObj.deliverGoodsType);
		}

	}
}

function chooseDelever(i) {
	$("#delever_" + i).addClass("pink").siblings().removeClass("pink");
	$("#deleverType").val(i);
	updateDeleverType(); //更新支付方式的缓存
}

function updateDeleverType() {
	var deleverType = $("#deleverType").val();
	updateCheckOutCache(UpdateBackFillItem.DELEVER_GOODS_TYPE, deleverType);
}

function invoiceAddressOperate(invoiceIsConsigneeId, invoiceAddressId) {
	var addresstype = AddressTypeEnums.SP;
	shareInvoiceAddressId = invoiceAddressId;
	if($(".showbtn-SP").length < 1 || !invoiceIsConsigneeId || invoiceIsConsigneeId == "0") {
		showInvoiceAddress();
	} else if(invoiceIsConsigneeId == "1") {
		// showConsignList("", invoiceAddressId, AddressTypeEnums.SP);
		$("#invoice-cb").prop("checked", true);
		$(".address-" + addresstype).removeClass("pink");
		$("#addressList-" + addresstype).hide();
	}
}

function contractAddressOperate(isSendContract, contractIsConsigneeId, contractAddressId) {
	var addresstype = AddressTypeEnums.HT;
	if(!isSendContract || isSendContract == "0") {
		showConsignList("", "", AddressTypeEnums.HT);
		$("#contract-is").hide();
	} else if(isSendContract == "1") {
		shareContractAddressId = contractAddressId;
		if(!contractIsConsigneeId || contractIsConsigneeId == "0") {
			showContractAddress();
		} else if(contractIsConsigneeId == "1") {
			showConsignList("", shareContractAddressId, addresstype);
			$("#contract-cb").prop("checked", true);
			$(".address-" + addresstype).removeClass("pink");
			$("#addressList-" + addresstype).hide();
		}
		$("#contract-is").show();
		$("#contract-send").prop("checked", true);
	}
}

function agree_conditon() {
	var phone = "";
	try {
		phone = temp.checkOutCart.vendors[0].sorted[0].item.phoneServiceNumber;
	} catch(e) {
		phone = "";
	}
	$("#agree_condition").empty();
	var dongde_agree = ' <span id="dongde_agree" ><input type="checkbox" name="isagreed" id="isagreed" checked="checked" latag="latag_pc_odersubmit_agree"><a target="_blank" href="turnDongde.jhtm?phone=' + phone + '" latag="latag_pc_odersubmit_turnb2c">' + orderResource.agree_contract + '</a> </span>';
	$("#agree_condition").html(dongde_agree);
}
//数据恢复险
function title_imgClick(_this) {
	$(_this).parent("b").find(".i_title").toggle();
	$(_this).parent("b").find(".jiao1").toggle();
	$(_this).parent("b").find(".jiao2").toggle();
}
//数据恢复险
function title_imgShow(_this) {
	$(_this).parent("b").find(".i_title").show();
	$(_this).parent("b").find(".jiao1").show();
	$(_this).parent("b").find(".jiao2").show();
}

function title_imgHide(_this) {
	$(_this).parent("b").find(".i_title").hide();
	$(_this).parent("b").find(".jiao1").hide();
	$(_this).parent("b").find(".jiao2").hide();
}

function dataRecoveryClick(_this, id, content) {
	$(_this).parents(".db_back").toggleClass("db_checked");
	if($(_this).parents(".db_back").hasClass("db_checked")) {
		datarecovery(id, content, 1);
	} else {
		datarecovery(id, content, 0);
	}
}
//提交产品信息
function submitGoods(products_c) {
	var gcodes_in_buy = [];
	for(var i = 0; i < products_c.length; i++) {
		var sortedList = products_c[i].sorted;
		for(var j = 0; j < sortedList.length; j++) {
			gcodes_in_buy.push(sortedList[j].item.id)
		}
	}
	var maingcodes = gcodes_in_buy.join('|');
	_trackData.push(['show', 'checkoutSubmit', 'latag_pc_odersubmit_submit_' + maingcodes]);

}

function submitOrder() {
	try {
		var Timeout;
		var onloadyes = false;
		var timeyes = false;
		var startime = +new Date;
		var a = (+new Date) + Math.random() * 100;
		var iframe = document.createElement("iframe");
		iframe.style.display = 'none';
		iframe.onload = iframe.onreadystatechange = function() {
			onloadyes = true;
			iframe.onload = iframe.onreadystatechange = null;
			$(iframe).remove();
			if(timeyes) return;
			submitOrder_detail(); //◊‘º∫µƒ¬ﬂº≠
		};
		iframe.src = "https://6895322.fls.doubleclick.net/activityi;src=6895322;type=lenov0;cat=___uv002;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1;num=" + a + "?";
		document.body.appendChild(iframe);
		/**
		 * time  ∂‡…Ÿ√Î∫Û÷¥––
		 * count  ∂‡…Ÿ√Î÷¥––“ª¥Œ
		 */
		(function(time, count) {
			var start = 0;

			function create(Callback) {
				return setTimeout(function() {
					if(start >= time) {
						Callback();
					} else {
						create(Callback);
					}
					start += count;
				}, count);
			}
			Timeout = create(function() {
				if(onloadyes) return;
				timeyes = true;
				submitOrder_detail(); ////◊‘º∫µƒ¬ﬂº≠
			});
		})(300, 60)
	} catch(e) {}
}

//提交订单
function submitOrder_detail() {
	try {
		if(products_c != null) {
			submitGoods(products_c);
		}
	} catch(e) {
		console.log(e);
	}
	if(shopId == 8) {

		if(getCheckEmpty($('.jszx_select').val())) {
			showMessage(3000, orderResource.select_or_added_invoice_info);
			return false;
		}
		if($('input[name=fpsx]').eq(0).is(':checked') && !$("#jszx_sure_cb").is(":checked")) {
			showMessage(3000, orderResource.proxy_purchase_confirmed);
			return false;
		}
		if(!$("#invoice-cb").is(":checked") && !shareInvoiceAddressId) {
			showMessage(3000, orderResource.select_or_added_invoice_address);
			return false;
		}
		if($("#contract-send").is(":checked") && !$("#contract-cb").is(":checked") && !shareContractAddressId) {
			showMessage(3000, orderResource.select_or_added_contract_address);
			return false;
		}
	} else if(shopId == 1 || shopId == 2 || shopId == 3) {
		if($("#invoice_type").html() == orderResource.value_added_tax_invoice && !shareInvoiceAddressId) {
			showMessage(3000, orderResource.select_or_added_invoice_address);
			return false;
		}
	}

	//协议校验
	var isagreed = $("#isagreed").is(":checked");
	if(!isagreed && shopId != 9) {
		if(type_t == "dongde") {
			showMessage(3000, orderResource.dongde_contract_select);
		} else {
			if(shopId == 2) {
				showMessage(3000, orderResource.thinkpad_contract_select);
			} else {
				showMessage(3000, orderResource.lenovo_contract_select);
			}
		}
		return;
	}
	// 验证服务商品SN码
	//    var snCodeList = $("input[id^='sncode_']");
	//    if(snCodeList != null && snCodeList.length > 0){
	//        var snCheckResult = true;
	//        for(var i = 0; i < snCodeList.length; i++){
	//            var snCode = snCodeList[i].value;
	//            var goodsId = snCodeList[i].id;
	//            var material_code = goodsId.split("_")[2];
	//            var ajaxdata = {SNCode: snCode, materialCode: material_code};
	//            $.ajax({
	//                type: "post",
	//                url: buy_order.URL.checkServiceSNCode(),
	//                async: false,
	//                data: ajaxdata,
	//                dataType: "json",
	//                success: function (data) {
	//                    if (data != null) {
	//                        if (data.rc == 0) {
	//                            snCheckResult = false;
	//                        }
	//                    }
	//                }
	//            });
	//        }
	//        if(!snCheckResult){
	//            showMessage(2000, '服务对应的SN码有误');
	//            return;
	//        }
	//    }

	//验证备注
	var remark = $("#ordermark").val();
	//var
	if(null != remark && '' != remark && remark.length > 45) {
		showMessage(3000, orderResource.order_remarks_exceed);
		return;
	}
	if(!isEmpty(remark) && !is_forbid(remark)) {
		showMessage(3000, orderResource.remark_include_illegal_character);
		return;
	}
	//验证客服经理编码
	var managercode = $("#managercode").val();
	if(null != managercode && '' != managercode && managercode.length > 30) {
		showMessage(3000, orderResource.customer_manager_code_exceed);
		return;
	}
	if(!isEmpty(managercode) && !is_forbid(managercode)) {
		showMessage(3000, orderResource.manager_code_include_illegal_character);
		return;
	}
	var teltext = $("#pre_phone").val();
	var flag = $("#presellflag").val();
	if((flag == true || flag == "true") & teltext == "") {
		showMessage(3000, orderResource.input_remain_pay_contact);
		return;
	}
	if((flag == true || flag == "true") & !check_mobile(teltext)) {
		showMessage(3000, orderResource.input_remain_pay_mobile_phone);
		return;
	}
	var tempOldButton = $('#submitbutton').html();
	var tempButton = "<button   style=\"font-size: 18px;cursor: pointer;margin-top: 2px;\">" + orderResource.in_submitting + "</button>";
	$('#submitbutton').html(tempButton);
	//预售所留电话
	//facode|100@facode|200
	var creditInfo = "";
	var aa = [];
	$(".usecredit input[type='checkbox']:checked").each(function() {
		var faCode = $(this).attr("id").split("_")[1];
		var creditAmount = $("#input_" + faCode).val();
		if(creditAmount && creditAmount != "") {
			creditInfo = creditInfo + faCode + "|" + creditAmount + "@";
		}
	}); //判断可用额度大小
	if(creditInfo.length > 0) {
		creditInfo = creditInfo.substring(0, creditInfo.length - 1);
	}
	var c2clenovo = "";
	if(shopId == 1 && $.cookie("c2clenovo") != null) {
		c2clenovo = $.cookie("c2clenovo");
	}
	var selectNormal = false;
	if($("#selectNormal").length != 0 && $("#selectNormal").is(":checked")) {
		selectNormal = true;
	}

	$.post(buy_order.URL.submitOrder(), {
		terminal: terminal,
		orderremark: remark,
		lid: lid,
		cmanagercode: managercode,
		preSaleMobile: teltext,
		creditInfo: creditInfo,
		c2clenovo: c2clenovo,
		selectNormal: selectNormal
	}, function(data) {
		if(data.rc != 0) {
			if(data.rc == 10014 || data.rc == 20101 || data.rc == 10010) {
				window.location.href = buy_order.URL.getcart();
			} else {
				showMessage(3000, data.msg);
				$('#submitbutton').html(tempOldButton);
			}
			return;
		}
		//成功
		var temp = data.data;
		monitor();
		google_monitor_callback(temp);
		//调转到支付页面
		/*window.location.replace(temp);*/
	}, 'json');
}

function monitor() {
	try {
		var a = (+new Date) + Math.random() * 100;

		var iframe = document.createElement("iframe");
		iframe.src = "https://6895322.fls.doubleclick.net/activityi;src=6895322;type=lenov0;cat=___uv002;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1;num=" + a + "?";
		iframe.style.display = 'none';
		iframe.onload = iframe.onreadystatechange = function() {

			iframe.onload = iframe.onreadystatechange = null;
			$(iframe).remove();

		};
		document.body.appendChild(iframe);
	} catch(e) {}
}

function google_monitor_callback(url) {

	//url = https://cashier.lenovo.com.cn/order/toPay.jhtm?orderMainCode=13382693&terminal=1&shopId=1&token=1feefd801ef0337e583d5107e2c0b3a7&tokenTimeStamp=1537258571919&t=1537258579633
	try {
		var from = url.indexOf('orderMainCode=') + 'orderMainCode='.length;
		var endIndex = url.indexOf('&', from);
		var orderid = url.substring(from, endIndex);
		ga('require', 'ec');

		checkout_monitor(cart);
		var revenue = $("#totalPrice").html().replace("￥", "");
		var coupon = $("#totaldiscount").html().replace("￥", "");
		var youhuij = $("#youhuij").html().replace("￥", "");
		var coupon = parseFloat(coupon) + parseFloat(youhuij);
		var shipping = $("#freight").html().replace("￥", "");

		ga('ec:setAction', 'purchase', {
			'id': orderid, //订单号
			'revenue': revenue, // 订单金额(currency)
			'coupon': coupon, //订单优惠
			'affiliation': 'Official Store - Online',
			'tax': 0, // 订单税 (currency).
			'shipping': shipping, // 运费 (currency).
		});
		var ids = [];
		for(var i = 0; i < cart.length; i++) {
			var product = cart[i];
			ids.push(product.id);
		}

		ga('send', 'event', 'OrderConfirm_PC', orderid, ids.join('_'), {
			'hitCallback': function() {
				window.location.replace(url);
			}
		});

	} catch(e) {
		window.location.replace(url);
	}
}

$(function() {
	$(".personal_title").click(function() {
		$(this).next().toggle();
		$(this).find("b").toggle();
	});
})

//保留两位小数,验证数目
function dochecked(obj) {
	var result = formatDouble($(obj).val());
	var faCode = $(obj).attr("id").split("_")[1];
	if(result && !isNaN(result)) {
		if(parseFloat($(obj).attr("creditLine")) < parseFloat(result)) {
			//obj.value="";
			showMessage(3000, orderResource.credit_insufficient);
			$("#check_" + faCode).attr("checked", false);
			return;
		} else if(parseFloat($(obj).attr("total")) < parseFloat(result)) {
			//obj.value="";
			showMessage(3000, orderResource.credit_must_less_than_order_amount);
			$("#check_" + faCode).attr("checked", false);
			return;
		} else {
			$(obj).val(result);
		}
	} else {
		$("#check_" + faCode).attr("checked", false);
		$(obj).val("");
	}
}

function updateChoose(obj) {
	var $faCode = $(obj).attr("id").split("_")[1];
	if($('#check_' + $faCode).is(':checked')) {
		$('#check_' + $faCode).attr("checked", false);
		updateCreditCache($('#check_' + $faCode));
	}
}

function updateCreditCache(obj) {
	var $faCode = $(obj).attr("id").split("_")[1];
	var credit = $("#input_" + $faCode);
	dochecked(credit);
	if(credit.val() == "") {
		$(obj).attr("checked", false);
		// showMessage(3000, orderResource.input_credit);
		return;
	}
	if($(obj).is(':checked')) {
		credit.attr("disabled", "disabled");
		credit.css("background-color", "rgba(208, 206, 206, 0.55)");
	} else {
		credit.attr("disabled", null);
		credit.css("background-color", "#fff");
	}
	//facode|100@facode|200
	var creditInfo = "";
	var aa = [];
	//  console.info("长度" + $(".usecredit input[type='checkbox']:checked").length);
	$(".usecredit input[type='checkbox']:checked").each(function() {
		var faCode = $(this).attr("id").split("_")[1];
		var creditAmount = $("#input_" + faCode).val();
		if(creditAmount && creditAmount != "") {
			creditInfo = creditInfo + faCode + "|" + creditAmount + "@";
		}
	}); //判断可用额度大小
	if(creditInfo.length > 0) {
		creditInfo = creditInfo.substring(0, creditInfo.length - 1);
		//  console.info("creditInfo:" + creditInfo);
	}
	updateCheckOutCacheNew(UpdateBackFillItem.CREDITINFO, creditInfo);
}

function formatDouble(x) {
	var f = parseFloat(x);
	if(isNaN(f)) {
		return false;
	}

	var f = Math.round(x * 100) / 100;
	var s = f.toString();
	var rs = s.indexOf('.');
	if(rs < 0) {
		rs = s.length;
		s += '.';
	}
	while(s.length <= rs + 2) {
		s += '0';
	}
	return s;
}